[TRUNK][UPDATE]

- adds abstaction layer to -Conversion and -Marshaller classes
(AbstractConversion with abstact method convertAll and AbstactMarshaller with abstract method marshallAll)
- moves the actual calls for export from coreExporter/ldnTermsExporter to their belonging marshaller classes which override the marshallAll method
- changes the terminal outputs for info messages from system.err to system.out and keeps system.err for actual error messages
- moves the parts which call the converter and exporter of each module (e.g. core, ldnTerms) from the cliTool to seperate classes (rootConverter, rootExporter)

git-svn-id: https://svn.libreccm.org/ccm/trunk@5263 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2018-02-09 15:16:16 +00:00
parent fdd9fb1ef5
commit 3bf87c0d9c
40 changed files with 1306 additions and 474 deletions

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
/**
* Abstract class for converting all trunk objects of a certain class into
* objects of their corresponding ng classes.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/7/18
*/
public abstract class AbstractConversion {
/**
* Retrieves all trunk objects of a certain class from the persistent
* storage and collects them in a list. Then calls for creating the
* equivalent ng objects focusing on keeping all the associations in tact.
*/
public abstract void convertAll();
}

View File

@ -32,5 +32,5 @@ public abstract class AbstractConverter {
* order, so that dependencies can only be set, where the objects have
* already been created.
*/
public abstract void startConversionToNg();
public abstract void startConversion();
}

View File

@ -24,10 +24,21 @@ package com.arsdigita.portation;
*/
public abstract class AbstractExporter {
protected static Format format;
protected static String pathName;
protected static boolean indentation = false;
protected static boolean indentation;
public static void setPath(String path) {
public static void setFormat(final Format aFormat) {
format = aFormat;
}
public static void setPath(final String path) {
pathName = path;
}
public static void setIndentation(final boolean ind) {
indentation = ind;
}
public abstract void startMarshaller();
}

View File

@ -18,17 +18,19 @@
*/
package com.arsdigita.portation;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
/**
@ -42,97 +44,108 @@ import java.util.List;
* @version created on 2/10/16
*/
public abstract class AbstractMarshaller<P extends Portable> {
private static final Logger log = Logger.getLogger(AbstractMarshaller.class);
private Format format;
private String filename;
private String pathName;
private String fileName;
private boolean indentation;
// XML specifics
ObjectMapper xmlMapper;
/**
* Passes the parameters for the file to which the ng objects shall be
* exported to down to its corresponding {@link AbstractMarshaller<P>}
* and then requests this {@link AbstractMarshaller<P>} to start the
* export of all its ng objects.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
public abstract void marshallAll(final Format format,
final String pathName,
final boolean indentation);
public void prepare(final Format format, String filename, boolean indentation) {
/**
* Prepares parameters for the export:
*
* @param format format of the exported file (e.g. xml)
* @param pathName path for the exported files
* @param fileName filenames
* @param indentation whether to use indentation or not
*/
protected void prepare(final Format format,
final String pathName,
final String fileName,
final boolean indentation) {
this.format = format;
switch (this.format) {
case XML:
this.filename = filename + ".xml";
// for additional configuration
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
xmlMapper = new XmlMapper(module);
if (indentation) {
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
//xmlMapper.registerModule(new JaxbAnnotationModule());
xmlMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
break;
default:
break;
}
this.pathName = pathName;
this.fileName = fileName;
this.indentation = indentation;
}
public void prepare(final Format format, String folderPath, String filename, boolean indentation) {
File file = new File(folderPath);
if (file.exists() || file.mkdirs()) {
prepare(format, folderPath + "/" + filename, indentation);
}
}
public void exportList(final List<P> exportList) {
File file = new File(filename);
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter(file);
} catch (IOException e) {
log.error(String.format("Unable to open a fileWriter for the file" +
" with the name %s.", file.getName()));
}
if (fileWriter != null) {
for (P object : exportList) {
String line = null;
/**
* Exports list of the same objects.
*
* @param exportList List of same objects
*/
protected void exportList(final List<P> exportList) {
ObjectMapper objectMapper = null;
switch (format) {
case XML:
// xml extension to filename
fileName += ".xml";
// xml mapper configuration
final JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
objectMapper = new XmlMapper(module);
break;
}
FileWriter fileWriter = null;
try {
line = xmlMapper.writeValueAsString(object);
//log.info(line);
} catch (IOException e) {
log.error(String.format(
"Unable to write objetct of %s as XML " +
"string with name %s in file %s.",
object.getClass(),
object.toString(),
file.getName()), e);
}
break;
final Path filePath = Paths.get(pathName, fileName);
Files.createFile(filePath);
default:
break;
final File file = new File(filePath.toString());
fileWriter = new FileWriter(file);
} catch (FileAlreadyExistsException e) {
// destination file already exists
} catch (IOException ex) {
System.err.printf("ERROR Unable to open a fileWriter for the file" +
" with the name %s.\n %s\n", fileName, ex);
}
if (objectMapper != null && fileWriter != null) {
if (indentation) {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
String line = null;
for (P object : exportList) {
try {
line = objectMapper.writeValueAsString(object);
} catch (JsonProcessingException ex) {
System.err.printf("ERROR Unable to write object of class " +
"%s as XML string with name %s " +
"in file %s.\n %s\n", object.getClass(),
object.toString(), fileName, ex);
}
if (line != null) {
try {
fileWriter.write(line);
fileWriter.write(System.getProperty("line.separator"));
} catch (IOException e) {
log.error(String.format(
"Unable to write to file with the name %s.",
file.getName()));
} catch (IOException ex) {
System.err.printf("ERROR Unable to write to file with" +
" the name %s.\n %s\n", fileName, ex);
}
}
}
try {
fileWriter.close();
} catch (IOException e) {
log.error(String.format("Unable to close a fileWriter for the" +
" file with the name %s.", file.getName()));
}
} catch (IOException ex) {
System.err.printf("ERROR Unable to close a fileWriter for" +
" a file with the name %s.\n %s\n", fileName, ex);
}
}
}
}

View File

@ -18,13 +18,10 @@
*/
package com.arsdigita.portation.cmd;
import com.arsdigita.portation.conversion.CoreConverter;
import com.arsdigita.portation.modules.CoreExporter;
import com.arsdigita.portation.AbstractExporter;
import com.arsdigita.portation.Format;
import com.arsdigita.util.cmd.Program;
import org.apache.commons.cli.CommandLine;
import org.apache.log4j.Logger;
import java.lang.reflect.Method;
/**
* A Commandline tool for exporting all the objects of specified classes to
@ -34,9 +31,6 @@ import java.lang.reflect.Method;
* @version created on 25.05.16
*/
public class ExportCliTool extends Program {
private final static Logger logger = Logger.getLogger(ExportCliTool.class);
/**
* Constructor for the command line tool.
*/
@ -104,30 +98,16 @@ public class ExportCliTool extends Program {
/**
* Method for converting all trunk objects into ng objects at once.
*/
@SuppressWarnings("unchecked")
private void convert() {
try {
System.err.println("Started conversions of systems objects to " +
System.out.println("Started conversions of systems objects to " +
"ng-objects:");
// Core conversions
CoreConverter.getInstance().startConversionToNg();
// Lnd-Terms conversions
Class cls = Class
.forName("com.arsdigita.london.terms.portation" +
".conversion.LdnTermsConverter");
if (cls != null) {
Method startConversionToNg = cls
.getDeclaredMethod("startConversionToNg");
startConversionToNg.invoke(cls.newInstance());
}
System.err.println("Finished conversions.");
System.out.printf("\n");
RootConverter.rootConversionExecution();
System.out.println("Finished conversions.");
System.out.print("\n");
} catch (Exception e) {
logger.error("ERROR while converting trunk-objects to " +
"ng-objects", e);
System.err.printf("ERROR while converting trunk-objects to " +
"ng-objects: %s\n", e);
e.printStackTrace();
}
}
@ -138,41 +118,30 @@ public class ExportCliTool extends Program {
*
* @param args The secondary command line arguments
*/
@SuppressWarnings("unchecked")
private void export(String[] args) {
if (args.length != 2) {
printUsage();
System.exit(-1);
}
//final String moduleClass = args[1];
//System.err.printf("module-class: %s\n", moduleClass);
final Format format = Format.XML;
final String pathName = args[1];
System.err.printf("path for export: %s\n", pathName);
CoreExporter.setPath(pathName);
System.err.printf("\n");
final boolean ind = false;
System.out.printf("format to export to: %s\n", format.toString());
System.out.printf("path to export to: %s\n", pathName);
System.out.printf("indentations in files: %b\n", ind);
AbstractExporter.setFormat(format);
AbstractExporter.setPath(pathName);
AbstractExporter.setIndentation(ind);
System.out.print("\n");
try {
System.out.println("Started exporting all ng-objects:");
// Core
CoreExporter.startExport();
// Ldn-Terms
Class cls = Class
.forName("com.arsdigita.london.terms.portation.modules" +
".LdnTermsExporter");
if (cls != null) {
Method startExport = cls
.getDeclaredMethod("startExport");
startExport.invoke(cls.newInstance());
}
RootExporter.rootExportExecution();
System.out.println("Finished exports.");
System.out.printf("\n");
System.out.print("\n");
} catch (Exception ex) {
logger.error("ERROR while exporting", ex);
System.err.printf("ERROR while exporting: %s\n", ex);
}
}
@ -180,25 +149,25 @@ public class ExportCliTool extends Program {
* Prints the usage of this command line tool.
*/
private void printUsage() {
System.err.printf(
System.out.print(
"\n" +
"\t\t\t --- ExportCliTool ---\n" +
"\t\t\t\t --- ExportCliTool ---\n" +
"\n" +
"usage:\t<command> <module-class> <path>\n" +
"Usage:\t<command>\n" +
"\n" +
"Available commands:\n" +
"\thelp" +
"\t\t\t\t\t Shows information on how to use this tool.\n" +
"\tconvert" +
"\t\t\t\t\t Converts all trunk objects to ng objects.\n" +
"\texport <module-class> <path>" +
"\t\t Exports the chosen module class to a file\n" +
"\texport <path>" +
"\t\t\t\t Exports the chosen module class to a file\n" +
"\t\t\t\t" +
"\t\t at the location specified by the given path." +
"\n" +
"\n" +
"Available module-classes for export:\n" +
" \t\t categories \t\t all categories of the system\n" +
/*" \t\t categories \t\t all categories of the system\n" +
" \t\t categorizations \t\t all categorizations of the system\n" +
" \t\t users \t\t all users of the system\n" +
" \t\t groups \t\t all groups of the system\n" +
@ -212,9 +181,8 @@ public class ExportCliTool extends Program {
" \t\t permissions \t\t all permissions of the system\n" +
" \n" +
" \t\t default: \t\t all objects of the entire core module" +
*/"\n" +
"\n" +
"\n" +
"" +
"Do use for exporting java objects of a specified class.\n" +
"\n"
);

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.cmd;
import com.arsdigita.portation.conversion.CoreConverter;
import java.lang.reflect.Method;
/**
* Helper class to bundle all conversion calls.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/7/18
*/
public class RootConverter {
/**
* Root method to call all conversions.
*
* @throws Exception if classes outwards of core will not be found
*/
@SuppressWarnings("unchecked")
public static void rootConversionExecution() throws Exception {
// Core conversions
CoreConverter.getInstance().startConversion();
// Lnd-Terms conversions
Class cls = Class
.forName("com.arsdigita.london.terms.portation" +
".conversion.LdnTermsConverter");
if (cls != null) {
Method startConversionToNg = cls
.getDeclaredMethod("startConversion");
startConversionToNg.invoke(cls.newInstance());
}
// ...
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.cmd;
import com.arsdigita.portation.modules.CoreExporter;
import java.lang.reflect.Method;
/**
* Helper class to bundle all export calls.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/7/18
*/
public class RootExporter {
/**
* Root method to call all exportation
*
* @throws Exception if classes outwards of core will not be found
*/
@SuppressWarnings("unchecked")
public static void rootExportExecution() throws Exception {
// Core
CoreExporter.getInstance().startMarshaller();
// Ldn-Terms
Class cls = Class
.forName("com.arsdigita.london.terms.portation.modules" +
".LdnTermsExporter");
if (cls != null) {
Method startExport = cls
.getDeclaredMethod("startMarshaller");
startExport.invoke(cls.newInstance());
}
// ...
}
}

View File

@ -47,20 +47,29 @@ public class CoreConverter extends AbstractConverter {
instance = new CoreConverter();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static CoreConverter getInstance() {
return instance;
}
/**
* Method, to start all the different converter classes in a specific
* order, so that dependencies can only be set, where the objects have
* already been created.
*/
@Override
public void startConversionToNg() {
UserConversion.convertAll();
GroupConversion.convertAll();
RoleConversion.convertAll();
public void startConversion() {
UserConversion.getInstance().convertAll();
GroupConversion.getInstance().convertAll();
RoleConversion.getInstance().convertAll();
CategoryConversion.convertAll();
CategoryConversion.getInstance().convertAll();
PermissionConversion.convertAll();
PermissionConversion.getInstance().convertAll();
// Verify permissions
for (Permission permission : NgCoreCollection.permissions.values()) {
if (permission.getGrantee() == null) {
@ -70,17 +79,8 @@ public class CoreConverter extends AbstractConverter {
}
}
WorkflowConversion.convertAll();
TaskCommentConversion.convertAll();
AssignableTaskConversion.convertAll();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static CoreConverter getInstance() {
return instance;
WorkflowConversion.getInstance().convertAll();
TaskCommentConversion.getInstance().convertAll();
AssignableTaskConversion.getInstance().convertAll();
}
}

View File

@ -20,6 +20,7 @@ package com.arsdigita.portation.conversion.core.categorization;
import com.arsdigita.categorization.CategorizedCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.categorization.Categorization;
import com.arsdigita.portation.modules.core.categorization.Category;
@ -37,7 +38,12 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 29.6.16
*/
public class CategoryConversion {
public class CategoryConversion extends AbstractConversion {
private static CategoryConversion instance;
static {
instance = new CategoryConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.categorization.Category}s from
@ -45,19 +51,20 @@ public class CategoryConversion {
* creating the equivalent ng-{@link Category}s focusing on keeping all the
* associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching categories from database...");
@Override
public void convertAll() {
System.out.print("\tFetching categories from database...");
List<com.arsdigita.categorization.Category> trunkCategories = com
.arsdigita.categorization.Category.getAllObjectCategories();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting categories and categorizations...\n");
System.out.print("\tConverting categories and categorizations...\n");
createCategoryAndCategorizations(trunkCategories);
setRingAssociations(trunkCategories);
System.err.printf("\tSorting categories...\n");
System.out.print("\tSorting categories...\n");
sortCategoryMap();
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -68,7 +75,7 @@ public class CategoryConversion {
* {@link com.arsdigita.categorization.Category}s
* from this old trunk-system.
*/
private static void createCategoryAndCategorizations(
private void createCategoryAndCategorizations(
List<com.arsdigita.categorization.Category> trunkCategories) {
int processedCategories = 0, processedCategorizations = 0;
@ -88,7 +95,7 @@ public class CategoryConversion {
processedCategories++;
}
System.err.printf("\t\tCreated %d categories and\n" +
System.out.printf("\t\tCreated %d categories and\n" +
"\t\tcreated %d categorizations.\n",
processedCategories, processedCategorizations);
}
@ -104,7 +111,7 @@ public class CategoryConversion {
*
* @return Number of how many {@link Categorization}s have been processed.
*/
private static long createCategorizations(Category category,
private long createCategorizations(Category category,
CategorizedCollection
categorizedObjects) {
int processed = 0;
@ -140,7 +147,7 @@ public class CategoryConversion {
* {@link com.arsdigita.categorization.Category}s
* from this old trunk-system.
*/
private static void setRingAssociations(
private void setRingAssociations(
List<com.arsdigita.categorization.Category> trunkCategories) {
for (com.arsdigita.categorization.Category
trunkCategory : trunkCategories) {
@ -176,7 +183,7 @@ public class CategoryConversion {
* Runs once over the unsorted map and iterates over each their parents
* to add them to the sorted list.
*/
private static void sortCategoryMap() {
private void sortCategoryMap() {
ArrayList<Category> sortedList = new ArrayList<>();
int runs = 0;
@ -190,7 +197,7 @@ public class CategoryConversion {
}
NgCoreCollection.sortedCategories = sortedList;
System.err.printf("\t\tSorted categories in %d runs.\n", runs);
System.out.printf("\t\tSorted categories in %d runs.\n", runs);
}
/**
@ -200,7 +207,7 @@ public class CategoryConversion {
* @param sortedList Map of already sorted categories
* @param category Current category
*/
private static void addParent(ArrayList<Category> sortedList, Category
private void addParent(ArrayList<Category> sortedList, Category
category) {
Category parent = category.getParentCategory();
@ -211,4 +218,13 @@ public class CategoryConversion {
sortedList.add(parent);
}
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static CategoryConversion getInstance() {
return instance;
}
}

View File

@ -19,6 +19,7 @@
package com.arsdigita.portation.conversion.core.security;
import com.arsdigita.kernel.UserCollection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.security.Group;
import com.arsdigita.portation.modules.core.security.GroupMembership;
@ -34,7 +35,12 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 4.7.16
*/
public class GroupConversion {
public class GroupConversion extends AbstractConversion {
private static GroupConversion instance;
static {
instance = new GroupConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.kernel.Group}s from the
@ -43,15 +49,16 @@ public class GroupConversion {
* trunk-system. Then calls for creating the equivalent ng-{@link Group}s
* focusing on keeping all the associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching groups from database...");
@Override
public void convertAll() {
System.out.print("\tFetching groups from database...");
List<com.arsdigita.kernel.Group> trunkGroups = com.arsdigita.kernel
.Group.getAllObjectGroups();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting groups and group memberships...\n");
System.out.print("\tConverting groups and group memberships...\n");
createGroupsAndSetAssociations(trunkGroups);
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -61,7 +68,7 @@ public class GroupConversion {
* @param trunkGroups List of all {@link com.arsdigita.kernel.Group}s
* from this old trunk-system.
*/
private static void createGroupsAndSetAssociations(
private void createGroupsAndSetAssociations(
List<com.arsdigita.kernel.Group> trunkGroups) {
int pGroups = 0, pMemberships = 0;
@ -75,7 +82,7 @@ public class GroupConversion {
pGroups++;
}
System.err.printf("\t\tCreated %d groups and\n" +
System.out.printf("\t\tCreated %d groups and\n" +
"\t\tcreated %d group memberships.\n",
pGroups, pMemberships);
}
@ -90,7 +97,7 @@ public class GroupConversion {
* {@link com.arsdigita.kernel.User}s belonging to
* the given group
*/
private static long createGroupMemberships(Group group, UserCollection
private long createGroupMemberships(Group group, UserCollection
userCollection) {
int processed = 0;
@ -115,4 +122,12 @@ public class GroupConversion {
return processed;
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static GroupConversion getInstance() {
return instance;
}
}

View File

@ -19,6 +19,7 @@
package com.arsdigita.portation.conversion.core.security;
import com.arsdigita.kernel.RoleCollection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.security.*;
@ -39,8 +40,13 @@ import java.util.stream.Collectors;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 14.7.16
*/
public class PermissionConversion {
private static int rolesCreated = 0;
public class PermissionConversion extends AbstractConversion {
private static PermissionConversion instance;
private int rolesCreated = 0;
static {
instance = new PermissionConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.kernel.permissions.Permission}s
@ -49,14 +55,15 @@ public class PermissionConversion {
* the associations in tact. The association to the {@code
* grantee}-{@link Role} has to be recreated separately.
*/
public static void convertAll() {
System.err.printf("\tFetching permissions from database...");
@Override
public void convertAll() {
System.out.print("\tFetching permissions from database...");
List<com.arsdigita.kernel.permissions.Permission> trunkPermissions =
com.arsdigita.kernel.permissions.Permission
.getAllObjectPermissions();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting permissions...\n");
System.out.print("\tConverting permissions...\n");
createPermissionsAndSetAssociations(trunkPermissions);
try {
@ -68,7 +75,7 @@ public class PermissionConversion {
System.exit(-1);
}
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -79,7 +86,7 @@ public class PermissionConversion {
* {@link com.arsdigita.kernel.permissions.Permission}s
* from the old trunk-system
*/
private static void createPermissionsAndSetAssociations(final List<com
private void createPermissionsAndSetAssociations(final List<com
.arsdigita.kernel.permissions.Permission> trunkPermissions) {
int processed = 0, skipped = 0;
@ -95,7 +102,7 @@ public class PermissionConversion {
.get("id")).longValue()
|| -200 == ((BigDecimal) trunkPermission.getPartyOID()
.get("id")).longValue()) {
/*System.err.println(
/*System.out.println(
"Skiping because it is a internal permission");*/
skipped++;
continue;
@ -125,7 +132,7 @@ public class PermissionConversion {
processed++;
}
System.err.printf("\t\tCreated %d permissions and skipped: %d.\n",
System.out.printf("\t\tCreated %d permissions and skipped: %d.\n",
processed, skipped);
}
@ -148,7 +155,7 @@ public class PermissionConversion {
* {@link com.arsdigita.kernel.permissions.Permission}s
* from the old trunk-system
*/
private static void setGranteeDependency(final List<com.arsdigita.kernel
private void setGranteeDependency(final List<com.arsdigita.kernel
.permissions.Permission> trunkPermissions) {
int duplicates = 0;
@ -248,7 +255,7 @@ public class PermissionConversion {
trunkPermission.getACSObject().get("id")).longValue());
}
}
System.err.printf("\t\t(Created %d duplicates and created %d new " +
System.out.printf("\t\t(Created %d duplicates and created %d new " +
"roles.)\n", duplicates, rolesCreated);
}
@ -259,7 +266,7 @@ public class PermissionConversion {
*
* @return A role for the specified member
*/
private static Role getRoleIfExists(Party member) {
private Role getRoleIfExists(Party member) {
// might cause problems cause the
// task assignments are missing
String roleName = member.getName() + "_role";
@ -280,4 +287,13 @@ public class PermissionConversion {
return granteeRole;
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static PermissionConversion getInstance() {
return instance;
}
}

View File

@ -20,6 +20,7 @@ package com.arsdigita.portation.conversion.core.security;
import com.arsdigita.kernel.PartyCollection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.security.Party;
import com.arsdigita.portation.modules.core.security.Role;
@ -35,7 +36,12 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 4.7.16
*/
public class RoleConversion {
public class RoleConversion extends AbstractConversion{
private static RoleConversion instance;
static {
instance = new RoleConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.kernel.Role}s from the
@ -43,15 +49,16 @@ public class RoleConversion {
* creating the equivalent ng-{@link Role}s focusing on keeping all the
* associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching roles from database...");
@Override
public void convertAll() {
System.out.print("\tFetching roles from database...");
List<com.arsdigita.kernel.Role> trunkRoles = com.arsdigita.kernel
.Role.getAllObjectRoles();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tCreating roles and role memberships...\n");
System.out.print("\tCreating roles and role memberships...\n");
createRolesAndSetAssociations(trunkRoles);
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -61,7 +68,7 @@ public class RoleConversion {
* @param trunkRoles List of all {@link com.arsdigita.kernel.Role}s from
* this old trunk-system.
*/
private static void createRolesAndSetAssociations(
private void createRolesAndSetAssociations(
List<com.arsdigita.kernel.Role> trunkRoles) {
int pRoles = 0, pMemberships = 0;
@ -90,7 +97,7 @@ public class RoleConversion {
* {@link com.arsdigita.kernel.Party}s belonging to
* the given group
*/
private static long createRoleMemberships(Role role, PartyCollection
private long createRoleMemberships(Role role, PartyCollection
partyCollection) {
int processed = 0;
@ -112,4 +119,13 @@ public class RoleConversion {
return processed;
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static RoleConversion getInstance() {
return instance;
}
}

View File

@ -18,6 +18,7 @@
*/
package com.arsdigita.portation.conversion.core.security;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.modules.core.security.User;
import java.util.List;
@ -30,20 +31,26 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 4.7.16
*/
public class UserConversion {
public class UserConversion extends AbstractConversion {
private static UserConversion instance;
static {
instance = new UserConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.kernel.User}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link User}s.
*/
public static void convertAll() {
System.err.printf("\tFetching users from database...");
@Override
public void convertAll() {
System.out.print("\tFetching users from database...");
List<com.arsdigita.kernel.User> trunkUsers = com.arsdigita.kernel
.User.getAllObjectUsers();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting users...\n");
System.out.print("\tConverting users...\n");
// create users
int processed = 0;
for (com.arsdigita.kernel.User trunkUser : trunkUsers) {
@ -51,6 +58,15 @@ public class UserConversion {
processed++;
}
System.out.printf("\t\tCreated %d users.\n", processed);
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static UserConversion getInstance() {
return instance;
}
}

View File

@ -21,11 +21,11 @@ package com.arsdigita.portation.conversion.core.workflow;
import com.arsdigita.kernel.GroupCollection;
import com.arsdigita.kernel.RoleCollection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.security.Role;
import com.arsdigita.portation.modules.core.security.User;
import com.arsdigita.portation.modules.core.workflow.AssignableTask;
import com.arsdigita.portation.modules.core.workflow.Task;
import com.arsdigita.portation.modules.core.workflow.TaskAssignment;
import com.arsdigita.portation.modules.core.workflow.TaskComment;
import com.arsdigita.portation.modules.core.workflow.TaskDependency;
@ -44,8 +44,12 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 29.6.16
*/
public class AssignableTaskConversion {
public class AssignableTaskConversion extends AbstractConversion {
private static AssignableTaskConversion instance;
static {
instance = new AssignableTaskConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.workflow.simple.UserTask}s from
* the persistent storage and collects them in a list. Then calls for
@ -53,19 +57,20 @@ public class AssignableTaskConversion {
* associations in tact. The ring dependencies of class {@code Task} have
* to be recreated once all ng-{@link AssignableTask}s have been created.
*/
public static void convertAll() {
System.err.printf("\tFetching assignable tasks from database...");
@Override
public void convertAll() {
System.out.print("\tFetching assignable tasks from database...");
List<com.arsdigita.workflow.simple.UserTask> trunkUserTasks = com
.arsdigita.workflow.simple.UserTask.getAllObjectUserTasks();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting assignable tasks, task dependencies " +
System.out.print("\tConverting assignable tasks, task dependencies " +
"and task assignments...\n");
createAssignableTasksAndSetAssociations(trunkUserTasks);
System.err.printf("\tSorting task assignments...\n");
System.out.print("\tSorting task assignments...\n");
sortAssignableTaskMap();
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
@ -77,7 +82,7 @@ public class AssignableTaskConversion {
* {@link com.arsdigita.workflow.simple.UserTask}s
* from this old trunk-system.
*/
private static void createAssignableTasksAndSetAssociations(List<com.arsdigita
private void createAssignableTasksAndSetAssociations(List<com.arsdigita
.workflow.simple.UserTask> trunkUserTasks) {
int pTasks = 0, pAssignments = 0, pDependencies = 0;
@ -148,13 +153,13 @@ public class AssignableTaskConversion {
pTasks++;
/*System.err.printf("\t\tTasks: %d, " +
/*System.out.printf("\t\tTasks: %d, " +
"Dependencies: %d, " +
"Assignments: %d\n",
pTasks, pDependencies, pAssignments);*/
}
System.err.printf("\t\tCreated %d assignable tasks and\n" +
System.out.printf("\t\tCreated %d assignable tasks and\n" +
"\t\tCreated %d task dependencies and\n" +
"\t\tcreated %d task assignments.\n",
pTasks, pDependencies, pAssignments);
@ -172,7 +177,7 @@ public class AssignableTaskConversion {
* @param dependencyIt An iterator representing all dependencies of the
* given assignableTask
*/
private static long createTaskDependencies(AssignableTask assignableTask,
private long createTaskDependencies(AssignableTask assignableTask,
Iterator dependencyIt) {
int processed = 0;
@ -211,7 +216,7 @@ public class AssignableTaskConversion {
* {@link com.arsdigita.kernel.Role}s belonging to
* the assignableTask
*/
private static long createTaskAssignments(AssignableTask assignableTask,
private long createTaskAssignments(AssignableTask assignableTask,
GroupCollection groupCollection) {
int processed = 0;
@ -245,7 +250,7 @@ public class AssignableTaskConversion {
* Runs once over the unsorted map and iterates over each their dependencies
* to add them to the sorted list.
*/
private static void sortAssignableTaskMap() {
private void sortAssignableTaskMap() {
ArrayList<AssignableTask> sortedList = new ArrayList<>();
int runs = 0;
@ -262,7 +267,7 @@ public class AssignableTaskConversion {
}
NgCoreCollection.sortedAssignableTasks = sortedList;
System.err.printf("\t\tSorted assignable tasks in %d runs.\n", runs);
System.out.printf("\t\tSorted assignable tasks in %d runs.\n", runs);
}
/**
@ -273,7 +278,7 @@ public class AssignableTaskConversion {
* @param sortedList List of already sorted tasks
* @param assignableTask Current assignable task
*/
private static void addDependencies(ArrayList<AssignableTask> sortedList,
private void addDependencies(ArrayList<AssignableTask> sortedList,
AssignableTask assignableTask) {
List<TaskDependency> dependencies = assignableTask.getBlockingTasks();
@ -290,4 +295,13 @@ public class AssignableTaskConversion {
}
}
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static AssignableTaskConversion getInstance() {
return instance;
}
}

View File

@ -18,6 +18,7 @@
*/
package com.arsdigita.portation.conversion.core.workflow;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.security.User;
import com.arsdigita.portation.modules.core.workflow.TaskComment;
@ -33,7 +34,12 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 9/27/17
*/
public class TaskCommentConversion {
public class TaskCommentConversion extends AbstractConversion {
private static TaskCommentConversion instance;
static {
instance = new TaskCommentConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.workflow.simple.TaskComment}s
@ -41,15 +47,16 @@ public class TaskCommentConversion {
* creating the equivalent ng-{@link TaskComment}s focusing on keeping
* all the associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching task comments from database...");
@Override
public void convertAll() {
System.out.print("\tFetching task comments from database...");
List<com.arsdigita.workflow.simple.TaskComment> trunkTaskComments = com
.arsdigita.workflow.simple.TaskComment.getAllTaskComments();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting task comments...\n");
System.out.print("\tConverting task comments...\n");
createTaskCommentsAndSetAssociations(trunkTaskComments);
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
@ -61,7 +68,7 @@ public class TaskCommentConversion {
* {@link com.arsdigita.workflow.simple.TaskComment}s
* from this old trunk-system.
*/
private static void createTaskCommentsAndSetAssociations(
private void createTaskCommentsAndSetAssociations(
List<com.arsdigita.workflow.simple.TaskComment> trunkTaskComments) {
int processed = 0;
@ -82,6 +89,15 @@ public class TaskCommentConversion {
processed++;
}
System.err.printf("\t\tCreated %d task comments.\n", processed);
System.out.printf("\t\tCreated %d task comments.\n", processed);
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static TaskCommentConversion getInstance() {
return instance;
}
}

View File

@ -19,6 +19,7 @@
package com.arsdigita.portation.conversion.core.workflow;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.categorization.Category;
import com.arsdigita.portation.modules.core.core.CcmObject;
@ -39,26 +40,32 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 27.6.16
*/
public class WorkflowConversion {
public class WorkflowConversion extends AbstractConversion {
private static WorkflowConversion instance;
static {
instance = new WorkflowConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.workflow.simple.Workflow}s from
* the persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link Workflow}s.
*/
public static void convertAll() {
System.err.printf("\tFetching workflows from database...");
@Override
public void convertAll() {
System.out.print("\tFetching workflows from database...");
List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows =
com.arsdigita.workflow.simple.Workflow.getAllObjectWorkflows();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting workflows...\n");
System.out.print("\tConverting workflows...\n");
createWorkflowAndSetAssociations(trunkWorkflows);
setTemplateAssociations(trunkWorkflows);
System.err.printf("\tSorting workflows...\n");
System.out.print("\tSorting workflows...\n");
sortWorkflowMap();
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -69,7 +76,7 @@ public class WorkflowConversion {
* {@link com.arsdigita.workflow.simple.Workflow}s
* from this old trunk-system.
*/
private static void createWorkflowAndSetAssociations(
private void createWorkflowAndSetAssociations(
List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows) {
int processed = 0;
@ -90,7 +97,7 @@ public class WorkflowConversion {
processed++;
}
System.err.printf("\t\tCreated %d workflows.\n", processed);
System.out.printf("\t\tCreated %d workflows.\n", processed);
}
/**
@ -101,7 +108,7 @@ public class WorkflowConversion {
* {@link com.arsdigita.workflow.simple.Workflow}s
* from this old trunk-system.
*/
private static void setTemplateAssociations(
private void setTemplateAssociations(
List<com.arsdigita.workflow.simple.Workflow> trunkWorkflows) {
int processed = 0;
@ -123,7 +130,7 @@ public class WorkflowConversion {
} else
processed++;
}
System.err.printf("\t\tFound %d templates.\n", processed);
System.out.printf("\t\tFound %d templates.\n", processed);
}
/**
@ -134,7 +141,7 @@ public class WorkflowConversion {
* Runs once over the unsorted list and iterates over each their templates
* to add them to the sorted list.
*/
private static void sortWorkflowMap() {
private void sortWorkflowMap() {
ArrayList<Workflow> sortedList = new ArrayList<>();
int runs = 0;
@ -150,7 +157,7 @@ public class WorkflowConversion {
}
NgCoreCollection.sortedWorkflows = sortedList;
System.err.printf("\t\tSorted workflows in %d runs.\n", runs);
System.out.printf("\t\tSorted workflows in %d runs.\n", runs);
}
/**
@ -160,7 +167,7 @@ public class WorkflowConversion {
* @param sortedList List of already sorted workflows
* @param workflow Current workflow
*/
private static void addTemplate(ArrayList<Workflow> sortedList, Workflow
private void addTemplate(ArrayList<Workflow> sortedList, Workflow
workflow) {
Workflow template = workflow.getTemplate();
@ -171,4 +178,13 @@ public class WorkflowConversion {
sortedList.add(template);
}
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static WorkflowConversion getInstance() {
return instance;
}
}

View File

@ -36,161 +36,52 @@ import java.util.ArrayList;
* @version created on 25.07.2016
*/
public class CoreExporter extends AbstractExporter {
public static void startExport() {
exportUsers();
exportGroups();
exportGroupMemberships();
exportRoles();
exportRoleMemberships();
exportCategories();
exportCategorizations();
private static CoreExporter instance;
exportPermissions();
exportWorkflows();
exportTaskComments();
exportAssignableTasks();
exportTaskDependencies();
exportTaskAssignments();
static {
instance = new CoreExporter();
}
private static void exportUsers() {
System.out.printf("\tExporting users...");
UserMarshaller userMarshaller = new UserMarshaller();
userMarshaller.prepare(
Format.XML, pathName, "users", indentation);
userMarshaller.exportList(
new ArrayList<>(NgCoreCollection.users.values()));
System.out.printf("\t\tdone.\n");
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static CoreExporter getInstance() {
return instance;
}
private static void exportGroups() {
System.out.printf("\tExporting groups...");
GroupMarshaller groupMarshaller = new GroupMarshaller();
groupMarshaller.prepare(
Format.XML, pathName, "groups", indentation);
groupMarshaller.exportList(
new ArrayList<>(NgCoreCollection.groups.values()));
System.out.printf("\t\tdone.\n");
}
@Override
public void startMarshaller() {
UserMarshaller.getInstance().
marshallAll(format, pathName, indentation);
GroupMarshaller.getInstance().
marshallAll(format, pathName, indentation);
GroupMembershipMarshaller.getInstance().
marshallAll(format, pathName, indentation);
RoleMarshaller.getInstance().
marshallAll(format, pathName, indentation);
RoleMembershipMarshaller.getInstance().
marshallAll(format, pathName, indentation);
private static void exportGroupMemberships() {
System.out.printf("\tExporting group memberships...");
GroupMembershipMarshaller groupMembershipMarshaller = new
GroupMembershipMarshaller();
groupMembershipMarshaller.prepare(
Format.XML, pathName, "groupMemberships", indentation);
groupMembershipMarshaller.exportList(
new ArrayList<>(NgCoreCollection.groupMemberships.values()));
System.out.printf("\tdone.\n");
}
CategoryMarshaller.getInstance().
marshallAll(format, pathName, indentation);
CategorizationMarshaller.getInstance().
marshallAll(format, pathName, indentation);
private static void exportRoles() {
System.out.printf("\tExporting roles...");
RoleMarshaller roleMarshaller = new RoleMarshaller();
roleMarshaller.prepare(
Format.XML, pathName, "roles", indentation);
roleMarshaller.exportList(
new ArrayList<>(NgCoreCollection.roles.values()));
System.out.printf("\t\tdone.\n");
}
PermissionMarshaller.getInstance().
marshallAll(format, pathName, indentation);
private static void exportRoleMemberships() {
System.out.printf("\tExporting role memberships...");
RoleMembershipMarshaller roleMembershipMarshaller = new
RoleMembershipMarshaller();
roleMembershipMarshaller.prepare(
Format.XML, pathName, "roleMemberships", indentation);
roleMembershipMarshaller.exportList(
new ArrayList<>(NgCoreCollection.roleMemberships.values()));
System.out.printf("\tdone.\n");
}
private static void exportCategories() {
System.out.printf("\tExporting categories...");
CategoryMarshaller categoryMarshaller = new CategoryMarshaller();
categoryMarshaller.prepare(
Format.XML, pathName, "categories", indentation);
categoryMarshaller.exportList(
NgCoreCollection.sortedCategories);
System.out.printf("\t\tdone.\n");
}
private static void exportCategorizations() {
System.out.printf("\tExporting categorizations...");
CategorizationMarshaller categorizationMarshaller = new
CategorizationMarshaller();
categorizationMarshaller.prepare(
Format.XML, pathName, "categorizations", indentation);
categorizationMarshaller.exportList(
new ArrayList<>(NgCoreCollection.categorizations.values()));
System.out.printf("\tdone.\n");
}
private static void exportPermissions() {
System.out.printf("\tExporting permissions...");
PermissionMarshaller permissionMarshaller = new
PermissionMarshaller();
permissionMarshaller.prepare(
Format.XML, pathName, "permissions", indentation);
permissionMarshaller.exportList(
new ArrayList<>(NgCoreCollection.permissions.values()));
System.out.printf("\tdone.\n");
}
private static void exportWorkflows() {
System.out.printf("\tExporting workflows...");
WorkflowMarshaller workflowMarshaller = new WorkflowMarshaller();
workflowMarshaller.prepare(
Format.XML, pathName, "workflows", indentation);
workflowMarshaller.exportList(
NgCoreCollection.sortedWorkflows);
System.out.printf("\t\tdone.\n");
}
private static void exportTaskComments() {
System.out.printf("\tExporting task comments...");
TaskCommentMarshaller taskCommentMarshaller = new
TaskCommentMarshaller();
taskCommentMarshaller.prepare(
Format.XML, pathName, "taskComments", indentation);
taskCommentMarshaller.exportList(
new ArrayList<>(NgCoreCollection.taskComments.values()));
System.out.printf("\tdone.\n");
}
private static void exportAssignableTasks() {
System.out.printf("\tExporting assignable tasks...");
AssignableTaskMarshaller assignableTaskMarshaller = new
AssignableTaskMarshaller();
assignableTaskMarshaller.prepare(
Format.XML, pathName, "assignableTasks", indentation);
assignableTaskMarshaller.exportList(
NgCoreCollection.sortedAssignableTasks);
System.out.printf("\tdone.\n");
}
private static void exportTaskDependencies() {
System.out.printf("\tExporting task dependencies...");
TaskDependencyMarshaller taskDependencyMarshaller = new
TaskDependencyMarshaller();
taskDependencyMarshaller.prepare(
Format.XML, pathName, "taskDependencies", indentation);
taskDependencyMarshaller.exportList(
new ArrayList<>(NgCoreCollection.taskDependencies.values()));
System.out.printf("\tdone.\n");
}
private static void exportTaskAssignments() {
System.out.printf("\tExporting task assignments...");
TaskAssignmentMarshaller taskAssignmentMarshaller = new
TaskAssignmentMarshaller();
taskAssignmentMarshaller.prepare(
Format.XML, pathName, "taskAssignments", indentation);
taskAssignmentMarshaller.exportList(
new ArrayList<>(NgCoreCollection.taskAssignments.values()));
System.out.printf("\tdone.\n");
WorkflowMarshaller.getInstance().
marshallAll(format, pathName, indentation);
TaskCommentMarshaller.getInstance().
marshallAll(format, pathName, indentation);
AssignableTaskMarshaller.getInstance().
marshallAll(format, pathName, indentation);
TaskDependencyMarshaller.getInstance().
marshallAll(format, pathName, indentation);
TaskAssignmentMarshaller.getInstance().
marshallAll(format, pathName, indentation);
}
}

View File

@ -7,7 +7,7 @@
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHerr ANY WARRANTY; witherr even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.categorization;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class CategorizationMarshaller extends AbstractMarshaller<Categorization> {
private static CategorizationMarshaller instance;
static {
instance = new CategorizationMarshaller();
}
/**
* Getter for the instance of this singleton
*
* @return instance of the singleton
*/
public static CategorizationMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Categorization}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<Categorization>} and then requests this
* {@link AbstractMarshaller<Categorization>} to start the export of all
* its {@link Categorization}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting categorizations...");
prepare(format, pathName, "categorizations", indentation);
exportList(new ArrayList<>(NgCoreCollection.categorizations.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,47 @@
package com.arsdigita.portation.modules.core.categorization;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class CategoryMarshaller extends AbstractMarshaller<Category> {
private static CategoryMarshaller instance;
static {
instance = new CategoryMarshaller();
}
/**
* Gertter for the instance of the singleton
*
* @return instance of the singleton
*/
public static CategoryMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Category}-objects
* will be exported to down to its corresponding
* {@link AbstractMarshaller<Category>} and then requests this
* {@link AbstractMarshaller<Category>} to start the export of all its
* {@link Category}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting categories...");
prepare(format, pathName, "categories", indentation);
exportList(NgCoreCollection.sortedCategories);
System.out.print("\t\tdone.\n");
}
}

View File

@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 01.06.16
*/
public class GroupMarshaller extends AbstractMarshaller<Group> {
private static GroupMarshaller instance;
static {
instance = new GroupMarshaller();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static GroupMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Group}-objects
* will be exported to down to its corresponding
* {@link AbstractMarshaller<Group>} and then requests this
* {@link AbstractMarshaller<Group>} to start the export of all its
* {@link User}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting groups...");
prepare(format, pathName, "groups", indentation);
exportList(new ArrayList<>(NgCoreCollection.groups.values()));
System.out.print("\t\tdone.\n");
}
}

View File

@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class GroupMembershipMarshaller extends AbstractMarshaller<GroupMembership> {
private static GroupMembershipMarshaller instance;
static {
instance = new GroupMembershipMarshaller();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static GroupMembershipMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link GroupMembership}
* -objects will be exported to down to its corresponding
* {@link AbstractMarshaller<GroupMembership>} and then requests this
* {@link AbstractMarshaller<GroupMembership>} to start the export of all
* its {@link GroupMembership}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting group memberships...");
prepare(format, pathName, "groupMemberships", indentation);
exportList(new ArrayList<>(NgCoreCollection.groupMemberships.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class PermissionMarshaller extends AbstractMarshaller<Permission> {
private static PermissionMarshaller instance;
static {
instance = new PermissionMarshaller();
}
/**
* Getter for instance of this singleton.
*
* @return instance of the singleton
*/
public static PermissionMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Permission}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<Permission>} and then requests this
* {@link AbstractMarshaller<Permission>} to start the export of all its
* {@link Permission}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting permissions...");
prepare(format, pathName, "permissions", indentation);
exportList(new ArrayList<>(NgCoreCollection.permissions.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class RoleMarshaller extends AbstractMarshaller<Role> {
private static RoleMarshaller instance;
static {
instance = new RoleMarshaller();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static RoleMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Role}-objects
* will be exported to down to its corresponding
* {@link AbstractMarshaller<Role>} and then requests this
* {@link AbstractMarshaller<Role>} to start the export of all its
* {@link Role}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting roles...");
prepare(format, pathName, "roles", indentation);
exportList(new ArrayList<>(NgCoreCollection.roles.values()));
System.out.print("\t\tdone.\n");
}
}

View File

@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class RoleMembershipMarshaller extends AbstractMarshaller<RoleMembership> {
private static RoleMembershipMarshaller instance;
static {
instance = new RoleMembershipMarshaller();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static RoleMembershipMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link RoleMembership}
* -objects will be exported to down to its corresponding
* {@link AbstractMarshaller<RoleMembership>} and then requests this
* {@link AbstractMarshaller<RoleMembership>} to start the export of all
* its {@link RoleMembership}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting role memberships...");
prepare(format, pathName, "roleMemberships", indentation);
exportList(new ArrayList<>(NgCoreCollection.roleMemberships.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,48 @@
package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 25.05.16
*/
public class UserMarshaller extends AbstractMarshaller<User> {
private static UserMarshaller instance;
static {
instance = new UserMarshaller();
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static UserMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link User}-objects will
* be exported to down to its corresponding {@link AbstractMarshaller<User>}
* and then requests this {@link AbstractMarshaller<User>} to start the
* export of all its {@link User}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting users...");
prepare(format, pathName, "users", indentation);
exportList(new ArrayList<>(NgCoreCollection.users.values()));
System.out.print("\t\tdone.\n");
}
}

View File

@ -19,10 +19,47 @@
package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class AssignableTaskMarshaller extends AbstractMarshaller<AssignableTask> {
private static AssignableTaskMarshaller instance;
static {
instance = new AssignableTaskMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static AssignableTaskMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link AssignableTask}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<AssignableTask>} and then requests this
* {@link AbstractMarshaller<AssignableTask>} to start the export of all
* its {@link AssignableTask}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting assignable tasks...");
prepare(format, pathName, "assignableTasks", indentation);
exportList(NgCoreCollection.sortedAssignableTasks);
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,50 @@
package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class TaskAssignmentMarshaller extends AbstractMarshaller<TaskAssignment> {
private static TaskAssignmentMarshaller instance;
static {
instance = new TaskAssignmentMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static TaskAssignmentMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link TaskAssignment}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<TaskAssignment>} and then requests this
* {@link AbstractMarshaller<TaskAssignment>} to start the export of all
* its {@link TaskAssignment}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting task assignments...");
prepare(format, pathName, "taskAssignments", indentation);
exportList(new ArrayList<>(NgCoreCollection.taskAssignments.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,49 @@
package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 9/27/17
*/
public class TaskCommentMarshaller extends AbstractMarshaller<TaskComment> {
private static TaskCommentMarshaller instance;
static {
instance = new TaskCommentMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static TaskCommentMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link TaskComment}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<TaskComment>} and then requests this
* {@link AbstractMarshaller<TaskComment>} to start the export of all its
* {@link TaskComment}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting task comments...");
prepare(format, pathName, "taskComments", indentation);
exportList(new ArrayList<>(NgCoreCollection.taskComments.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -7,7 +7,7 @@
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHerr ANY WARRANTY; witherr even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
@ -19,6 +19,10 @@
package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -26,4 +30,39 @@ import com.arsdigita.portation.AbstractMarshaller;
*/
public class TaskDependencyMarshaller extends
AbstractMarshaller<TaskDependency> {
private static TaskDependencyMarshaller instance;
static {
instance = new TaskDependencyMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static TaskDependencyMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link TaskDependency}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<TaskDependency>} and then requests this
* {@link AbstractMarshaller<TaskDependency>} to start the export of all
* its {@link TaskDependency}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting task dependencies...");
prepare(format, pathName, "taskDependencies", indentation);
exportList(new ArrayList<>(NgCoreCollection.taskDependencies.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -19,10 +19,47 @@
package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.conversion.NgCoreCollection;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class WorkflowMarshaller extends AbstractMarshaller<Workflow> {
private static WorkflowMarshaller instance;
static {
instance = new WorkflowMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static WorkflowMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Workflow}-objects
* will be exported to down to its corresponding
* {@link AbstractMarshaller<Workflow>} and then requests this
* {@link AbstractMarshaller<Workflow>} to start the export of all its
* {@link Workflow}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting workflows...");
prepare(format, pathName, "workflows", indentation);
exportList(NgCoreCollection.sortedWorkflows);
System.out.print("\t\tdone.\n");
}
}

View File

@ -40,18 +40,6 @@ public class LdnTermsConverter extends AbstractConverter {
instance = new LdnTermsConverter();
}
/**
* Method, to start all the different converter classes in a specific
* order, so that dependencies can only be set, where the objects have
* already been created.
*/
@Override
public void startConversionToNg() {
ResourceTypeConversion.convertAll();
CcmApplicationConversion.convertAll();
DomainConversion.convertAll();
}
/**
* Getter for the instance of the singleton.
*
@ -60,4 +48,16 @@ public class LdnTermsConverter extends AbstractConverter {
public static LdnTermsConverter getInstance() {
return instance;
}
/**
* Method, to start all the different converter classes in a specific
* order, so that dependencies can only be set, where the objects have
* already been created.
*/
@Override
public void startConversion() {
ResourceTypeConversion.getInstance().convertAll();
CcmApplicationConversion.getInstance().convertAll();
DomainConversion.getInstance().convertAll();
}
}

View File

@ -26,6 +26,7 @@ import com.arsdigita.london.terms.portation.modules.core.categorization.Domain;
import com.arsdigita.london.terms.portation.modules.core.categorization.DomainOwnership;
import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.modules.core.categorization.Category;
import com.arsdigita.web.Application;
@ -39,7 +40,12 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/27/17
*/
public class DomainConversion {
public class DomainConversion extends AbstractConversion {
private static DomainConversion instance;
static {
instance = new DomainConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.london.terms.Domain}s from
@ -47,15 +53,16 @@ public class DomainConversion {
* creating the equivalent ng-{@link Domain}s focusing on keeping all the
* associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching domains from database...");
@Override
public void convertAll() {
System.out.print("\tFetching domains from database...");
List<com.arsdigita.london.terms.Domain> trunkDomains = com
.arsdigita.london.terms.Domain.getAllObjectDomains();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting domains and domain ownerships...\n");
System.out.print("\tConverting domains and domain ownerships...\n");
createDomainsAndSetAssociations(trunkDomains);
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -65,7 +72,7 @@ public class DomainConversion {
* @param trunkDomains List of all {@link com.arsdigita.london.terms.Domain}s
* from this old trunk-system.
*/
private static void createDomainsAndSetAssociations(
private void createDomainsAndSetAssociations(
List<com.arsdigita.london.terms.Domain> trunkDomains) {
int processedDomains = 0, processedDomainOwnerships = 0;
@ -91,7 +98,7 @@ public class DomainConversion {
processedDomains++;
}
System.err.printf("\t\tCreated %d domains and\n" +
System.out.printf("\t\tCreated %d domains and\n" +
"\t\tcreated %d domain ownerships.\n",
processedDomains, processedDomainOwnerships);
}
@ -107,7 +114,7 @@ public class DomainConversion {
*
* @return Number of how many {@link DomainOwnership}s have been processed.
*/
private static long createDomainOwnerships(Domain domain,
private long createDomainOwnerships(Domain domain,
DomainCollection useContexts) {
int processed = 0;
@ -142,5 +149,12 @@ public class DomainConversion {
return processed;
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static DomainConversion getInstance() {
return instance;
}
}

View File

@ -19,6 +19,7 @@
package com.arsdigita.london.terms.portation.conversion.core.core;
import com.arsdigita.london.terms.portation.modules.core.core.ResourceType;
import com.arsdigita.portation.AbstractConversion;
import java.util.List;
@ -30,20 +31,27 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class ResourceTypeConversion {
public class ResourceTypeConversion extends AbstractConversion {
private static ResourceTypeConversion instance;
static {
instance = new ResourceTypeConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.kernel.ResourceType}s from
* the persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link ResourceType}s focusing on keeping all
* the associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching resource types from database...");
@Override
public void convertAll() {
System.out.print("\tFetching resource types from database...");
List<com.arsdigita.kernel.ResourceType> trunkResourceTypes = com
.arsdigita.kernel.ResourceType.getAllObjectResourceTypes();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting domains...\n");
System.out.print("\tConverting domains...\n");
// create resource types
int processed = 0;
for (com.arsdigita.kernel.ResourceType trunkResourceType :
@ -52,6 +60,15 @@ public class ResourceTypeConversion {
processed++;
}
System.out.printf("\t\tCreated %d resource types.\n", processed);
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static ResourceTypeConversion getInstance() {
return instance;
}
}

View File

@ -23,6 +23,7 @@ import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.london.terms.portation.modules.core.core.Resource;
import com.arsdigita.london.terms.portation.modules.core.core.ResourceType;
import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.web.Application;
import java.util.ArrayList;
@ -36,28 +37,35 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class CcmApplicationConversion {
public class CcmApplicationConversion extends AbstractConversion {
private static CcmApplicationConversion instance;
static {
instance = new CcmApplicationConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.kernel.ResourceType}s from
* the persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link ResourceType}s focusing on keeping all
* the associations in tact.
*/
public static void convertAll() {
System.err.printf("\tFetching ccm applications from database...");
@Override
public void convertAll() {
System.out.print("\tFetching ccm applications from database...");
List<Application> trunkApplications = Application
.getAllApplicationObjects();
System.err.println("done.");
System.out.println("done.");
System.err.printf("\tConverting ccm applications...\n");
System.out.print("\tConverting ccm applications...\n");
// create ccm applications
createCcmApplicationsAndSetAssociations(trunkApplications);
setRingAssociations(trunkApplications);
System.err.printf("\tSorting ccm applications...\n");
System.out.print("\tSorting ccm applications...\n");
sortCcmApplications();
System.err.println("\tdone.\n");
System.out.println("\tdone.\n");
}
/**
@ -67,7 +75,7 @@ public class CcmApplicationConversion {
* @param trunkApplications List of all {@link Application}s
* from this old trunk-system.
*/
private static void createCcmApplicationsAndSetAssociations(
private void createCcmApplicationsAndSetAssociations(
List<Application> trunkApplications) {
int processed = 0;
@ -86,11 +94,9 @@ public class CcmApplicationConversion {
ccmApplication.setResourceType(resourceType);
}
//System.err.println(String.format(
// "ccm application id: %d", ccmApplication.getObjectId()));
processed++;
}
System.err.printf("\t\tCreated %d ccm applications.\n", processed);
System.out.printf("\t\tCreated %d ccm applications.\n", processed);
}
/**
@ -101,14 +107,14 @@ public class CcmApplicationConversion {
* @param trunkApplications List of all {@link Application} from the old
* trunk-system.
*/
private static void setRingAssociations(List<Application> trunkApplications) {
private void setRingAssociations(List<Application> trunkApplications) {
for (Application trunkApplication : trunkApplications) {
CcmApplication ccmApplication = NgCoreCollection
.ccmApplications
.get(trunkApplication.getID().longValue());
// set parent Resource and opposed association
CcmApplication parentResource = null;
CcmApplication parentResource;
Application trunkParent = trunkApplication
.getParentApplication();
@ -130,7 +136,7 @@ public class CcmApplicationConversion {
* Runs once over the unsorted list and iterates over each their parents
* to add them to the sorted list.
*/
private static void sortCcmApplications() {
private void sortCcmApplications() {
ArrayList<CcmApplication> sortedList = new ArrayList<>();
int runs = 0;
@ -145,7 +151,7 @@ public class CcmApplicationConversion {
}
NgCoreCollection.sortedCcmApplications = sortedList;
System.err.printf("\t\tSorted ccm applications in %d runs.\n", runs);
System.out.printf("\t\tSorted ccm applications in %d runs.\n", runs);
}
/**
@ -155,7 +161,7 @@ public class CcmApplicationConversion {
* @param sortedList List of already sorted assignable tasks
* @param ccmApplication Current assignable task
*/
private static void addResourceParent(ArrayList<CcmApplication> sortedList,
private void addResourceParent(ArrayList<CcmApplication> sortedList,
CcmApplication ccmApplication) {
CcmApplication resourceParent = (CcmApplication) ccmApplication
.getParent();
@ -167,4 +173,13 @@ public class CcmApplicationConversion {
sortedList.add(resourceParent);
}
}
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static CcmApplicationConversion getInstance() {
return instance;
}
}

View File

@ -25,6 +25,7 @@ import com.arsdigita.london.terms.portation.modules.core.categorization.DomainMa
import com.arsdigita.london.terms.portation.modules.core.web.CcmApplicationMarshaller;
import com.arsdigita.portation.AbstractExporter;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.modules.CoreExporter;
import java.util.ArrayList;
@ -40,53 +41,30 @@ import java.util.ArrayList;
*/
public class LdnTermsExporter extends AbstractExporter {
public static void startExport() {
exportResourceTypes();
exportCcmApplications();
exportDomains();
exportDomainOwnerships();
private static LdnTermsExporter instance;
static {
instance = new LdnTermsExporter();
}
private static void exportResourceTypes() {
System.out.printf("\tExporting resource types...");
ResourceTypeMarshaller resourceTypeMarshaller = new
ResourceTypeMarshaller();
resourceTypeMarshaller.prepare(
Format.XML, pathName, "resourceTypes", indentation);
resourceTypeMarshaller.exportList(
new ArrayList<>(NgCoreCollection.resourceTypes.values()));
System.out.printf("\tdone.\n");
/**
* Getter for the instance of the singleton.
*
* @return instance of this singleton
*/
public static LdnTermsExporter getInstance() {
return instance;
}
private static void exportCcmApplications() {
System.out.printf("\tExporting ccm applications...");
CcmApplicationMarshaller ccmApplicationMarshaller = new
CcmApplicationMarshaller();
ccmApplicationMarshaller.prepare(
Format.XML, pathName, "ccmApplications", indentation);
ccmApplicationMarshaller.exportList(
NgCoreCollection.sortedCcmApplications);
System.out.printf("\tdone.\n");
}
private static void exportDomains() {
System.out.printf("\tExporting domains...");
DomainMarshaller domainMarshaller = new DomainMarshaller();
domainMarshaller.prepare(
Format.XML, pathName, "domains", indentation);
domainMarshaller.exportList(
new ArrayList<>(NgCoreCollection.domains.values()));
System.out.printf("\t\tdone.\n");
}
private static void exportDomainOwnerships() {
System.out.printf("\tExporting domain ownerships...");
DomainOwnershipMarshaller domainOwnershipMarshaller = new
DomainOwnershipMarshaller();
domainOwnershipMarshaller.prepare(
Format.XML, pathName, "domainOwnerships", indentation);
domainOwnershipMarshaller.exportList(
new ArrayList<>(NgCoreCollection.domainOwnerships.values()));
System.out.printf("\tdone.\n");
@Override
public void startMarshaller() {
ResourceTypeMarshaller.getInstance().
marshallAll(format, pathName, indentation);
CcmApplicationMarshaller.getInstance().
marshallAll(format, pathName, indentation);
DomainMarshaller.getInstance().
marshallAll(format, pathName, indentation);
DomainOwnershipMarshaller.getInstance().
marshallAll(format, pathName, indentation);
}
}

View File

@ -18,11 +18,50 @@
*/
package com.arsdigita.london.terms.portation.modules.core.categorization;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/27/17
*/
public class DomainMarshaller extends AbstractMarshaller<Domain> {
private static DomainMarshaller instance;
static {
instance = new DomainMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static DomainMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link Domain}-objects
* will be exported to down to its corresponding
* {@link AbstractMarshaller<Domain>} and then requests this
* {@link AbstractMarshaller<Domain>} to start the export of all its
* {@link Domain}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting domains...");
prepare(format, pathName, "domains", indentation);
exportList(new ArrayList<>(NgCoreCollection.domains.values()));
System.out.print("\t\tdone.\n");
}
}

View File

@ -18,11 +18,50 @@
*/
package com.arsdigita.london.terms.portation.modules.core.categorization;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
public class DomainOwnershipMarshaller extends AbstractMarshaller<DomainOwnership>{
private static DomainOwnershipMarshaller instance;
static {
instance = new DomainOwnershipMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static DomainOwnershipMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link DomainOwnership}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<DomainOwnership>} and then requests this
* {@link AbstractMarshaller<DomainOwnership>} to start the export of all
* its {@link DomainOwnership}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting domainOwnerships...");
prepare(format, pathName, "domainOwnerships", indentation);
exportList(new ArrayList<>(NgCoreCollection.domainOwnerships.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -29,7 +29,7 @@ import java.util.Locale;
/**
* This class is a port of the old {@code ResourceType} entity.
*
* @deprecated The real purpose of this class is not clear. Also the
* /@deprecated The real purpose of this class is not clear. Also the
* informations provided by the entities of this class are all quite static or
* can be interfered from the classes itself. In modern Java most if not all the
* informations provided by the entities of this class would be expressed as

View File

@ -18,12 +18,50 @@
*/
package com.arsdigita.london.terms.portation.modules.core.core;
import com.arsdigita.london.terms.portation.modules.core.core.ResourceType;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import java.util.ArrayList;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/3/17
*/
public class ResourceTypeMarshaller extends AbstractMarshaller<ResourceType> {
private static ResourceTypeMarshaller instance;
static {
instance = new ResourceTypeMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static ResourceTypeMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link ResourceType}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<ResourceType>} and then requests this
* {@link AbstractMarshaller<ResourceType>} to start the export of all
* its {@link ResourceType}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting resourceTypes...");
prepare(format, pathName, "resourceTypes", indentation);
exportList(new ArrayList<>(NgCoreCollection.resourceTypes.values()));
System.out.print("\tdone.\n");
}
}

View File

@ -18,11 +18,48 @@
*/
package com.arsdigita.london.terms.portation.modules.core.web;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/3/17
*/
public class CcmApplicationMarshaller extends AbstractMarshaller<CcmApplication> {
private static CcmApplicationMarshaller instance;
static {
instance = new CcmApplicationMarshaller();
}
/**
* Getter for the instance of this singleton.
*
* @return instance of the singleton
*/
public static CcmApplicationMarshaller getInstance() {
return instance;
}
/**
* Passes the parameters for the file to which the {@link CcmApplication}-
* objects will be exported to down to its corresponding
* {@link AbstractMarshaller<CcmApplication>} and then requests this
* {@link AbstractMarshaller<CcmApplication>} to start the export of all
* its {@link CcmApplication}s.
*
* @param format The format of the file to which will be exported to
* @param pathName The name for the file
* @param indentation Whether to use indentation in the file
*/
@Override
public void marshallAll(final Format format,
final String pathName,
final boolean indentation) {
System.out.print("\tExporting ccmApplications...");
prepare(format, pathName, "ccmApplications", indentation);
exportList(NgCoreCollection.sortedCcmApplications);
System.out.print("\tdone.\n");
}
}