mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-11031: Persist object graph to file
Implemented so that the graph can actually be rendered to XML as a OutputStream, File, Writer. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31548 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.util.schemacomp;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.util.schemacomp.Difference.Where;
|
||||
import org.alfresco.util.schemacomp.model.Column;
|
||||
import org.alfresco.util.schemacomp.model.ForeignKey;
|
||||
import org.alfresco.util.schemacomp.model.Index;
|
||||
import org.alfresco.util.schemacomp.model.PrimaryKey;
|
||||
import org.alfresco.util.schemacomp.model.Table;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
|
||||
public class SchemaCompTestingUtils
|
||||
{
|
||||
public static void dumpValidation(List<ValidationResult> validationResults)
|
||||
{
|
||||
System.out.println("Validation Results (" + validationResults.size() + ")");
|
||||
for (ValidationResult r : validationResults)
|
||||
{
|
||||
System.out.println(r);
|
||||
}
|
||||
}
|
||||
|
||||
public static void dumpDiffs(Results differences, boolean showNonDifferences)
|
||||
{
|
||||
System.out.println("Differences (" + differences.size() + ")");
|
||||
for (Difference d : differences)
|
||||
{
|
||||
if (d.getWhere() != Where.IN_BOTH_NO_DIFFERENCE || showNonDifferences)
|
||||
{
|
||||
System.out.println(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Table table(String name)
|
||||
{
|
||||
return new Table(null, name, columns("id NUMBER(10)"), pk("pk_" + name, "id"), fkeys(), indexes());
|
||||
}
|
||||
|
||||
public static Table table(String name, Collection<Column> columns, PrimaryKey primaryKey,
|
||||
Collection<ForeignKey> foreignKeys, Collection<Index> indexes)
|
||||
{
|
||||
return new Table(null, name, columns, primaryKey, foreignKeys, indexes);
|
||||
}
|
||||
|
||||
public static Collection<Column> columns(String... colDefs)
|
||||
{
|
||||
assertTrue("Tables must have columns", colDefs.length > 0);
|
||||
Column[] columns = new Column[colDefs.length];
|
||||
|
||||
for (int i = 0; i < colDefs.length; i++)
|
||||
{
|
||||
String[] parts = colDefs[i].split(" ");
|
||||
columns[i] = new Column(null, parts[0], parts[1], false);
|
||||
}
|
||||
return Arrays.asList(columns);
|
||||
}
|
||||
|
||||
public static PrimaryKey pk(String name, String... columnNames)
|
||||
{
|
||||
assertTrue("No columns specified", columnNames.length > 0);
|
||||
PrimaryKey pk = new PrimaryKey(null, name, Arrays.asList(columnNames));
|
||||
return pk;
|
||||
}
|
||||
|
||||
public static List<ForeignKey> fkeys(ForeignKey... fkeys)
|
||||
{
|
||||
return Arrays.asList(fkeys);
|
||||
}
|
||||
|
||||
public static ForeignKey fk(String fkName, String localColumn, String targetTable, String targetColumn)
|
||||
{
|
||||
return new ForeignKey(null, fkName, localColumn, targetTable, targetColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create collection of indexes using strings of format "name column1 [column2 ... columnN]"
|
||||
*/
|
||||
public static Collection<Index> indexes(String... indexDefs)
|
||||
{
|
||||
Index[] indexes = new Index[indexDefs.length];
|
||||
for (int i = 0; i < indexDefs.length; i++)
|
||||
{
|
||||
String[] parts = indexDefs[i].split(" ");
|
||||
String name = parts[0];
|
||||
String[] columns = (String[]) ArrayUtils.subarray(parts, 1, parts.length);
|
||||
indexes[i] = new Index(null, name, Arrays.asList(columns));
|
||||
}
|
||||
return Arrays.asList(indexes);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user