From a5c1645bd8c90973fe2451ac0726ee012be4eb6e Mon Sep 17 00:00:00 2001 From: tosmers Date: Fri, 28 Jul 2017 16:34:07 +0000 Subject: [PATCH] [TRUNK][Feature] - adds capability of converting trunks ldn-terms' domain objects to ng's core domain objects - modifies structure of portation packages and deletes Marshaller.java git-svn-id: https://svn.libreccm.org/ccm/trunk@4889 8810af33-2d31-482b-a856-94f89814c4df --- .../portation/AbstractConverter.java | 36 ++++ .../arsdigita/portation/AbstractExporter.java | 33 ++++ .../com/arsdigita/portation/Marshaller.java | 115 ----------- .../arsdigita/portation/cmd/CoreExporter.java | 181 ------------------ .../portation/cmd/ExportCliTool.java | 87 +++++---- .../portation/conversion/CoreConverter.java | 31 ++- ...gCollection.java => NgCoreCollection.java} | 54 +++--- .../categorization/CategoryConversion.java | 8 +- .../core/security/GroupConversion.java | 4 +- .../core/security/PermissionConversion.java | 24 +-- .../core/security/RoleConversion.java | 4 +- .../workflow/AssignableTaskConversion.java | 16 +- .../core/workflow/WorkflowConversion.java | 7 +- .../portation/modules/CoreExporter.java | 176 +++++++++++++++++ .../core/categorization/Categorization.java | 10 +- .../modules/core/categorization/Category.java | 10 +- .../modules/core/core/CcmObject.java | 17 +- .../modules/core/l10n/LocalizedString.java | 6 +- .../modules/core/security/Group.java | 9 +- .../core/security/GroupMembership.java | 9 +- .../modules/core/security/Party.java | 4 +- .../modules/core/security/Permission.java | 11 +- .../portation/modules/core/security/Role.java | 17 +- .../modules/core/security/RoleMembership.java | 9 +- .../portation/modules/core/security/User.java | 15 +- .../modules/core/workflow/AssignableTask.java | 9 +- .../portation/modules/core/workflow/Task.java | 4 +- .../modules/core/workflow/TaskAssignment.java | 9 +- .../modules/core/workflow/Workflow.java | 13 +- .../core/workflow/WorkflowTemplate.java | 4 +- .../com/arsdigita/london/terms/Domain.java | 33 +++- .../conversion/LdnTermsConverter.java | 59 ++++++ .../conversion/NgCoreCollection.java | 37 ++++ .../core/categorization/DomainConversion.java | 79 ++++++++ .../portation/modules/LdnTermsExporter.java | 47 +++++ .../modules/core/categorization/Domain.java | 145 ++++++++++++++ .../core/categorization/DomainMarshaller.java | 13 +- .../core/categorization/DomainOwnership.java | 90 +++++++++ .../portation/modules/core/core/Resource.java | 105 ++++++++++ .../modules/core/core/ResourceType.java | 102 ++++++++++ .../modules/core/web/CcmApplication.java | 66 +++++++ 41 files changed, 1181 insertions(+), 527 deletions(-) create mode 100644 ccm-core/src/com/arsdigita/portation/AbstractConverter.java create mode 100644 ccm-core/src/com/arsdigita/portation/AbstractExporter.java delete mode 100644 ccm-core/src/com/arsdigita/portation/Marshaller.java delete mode 100644 ccm-core/src/com/arsdigita/portation/cmd/CoreExporter.java rename ccm-core/src/com/arsdigita/portation/conversion/{NgCollection.java => NgCoreCollection.java} (73%) create mode 100644 ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/LdnTermsConverter.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/NgCoreCollection.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/categorization/DomainConversion.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/Domain.java rename ccm-core/src/com/arsdigita/portation/Portable.java => ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainMarshaller.java (73%) create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/DomainOwnership.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/Resource.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/ResourceType.java create mode 100644 ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplication.java diff --git a/ccm-core/src/com/arsdigita/portation/AbstractConverter.java b/ccm-core/src/com/arsdigita/portation/AbstractConverter.java new file mode 100644 index 000000000..50ab948c9 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/AbstractConverter.java @@ -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 super class for conversion from trunk objects to ng object. The + * class demands the implementation of the following method of the + * appropriate converters. + * + * @author Tobias Osmers<\a> + * @version created the 7/28/17 + */ +public abstract class AbstractExporter { + + protected static String pathName; + protected static boolean indentation = false; + + public static void setPath(String path) { + pathName = path; + } +} diff --git a/ccm-core/src/com/arsdigita/portation/Marshaller.java b/ccm-core/src/com/arsdigita/portation/Marshaller.java deleted file mode 100644 index bbb2d3eea..000000000 --- a/ccm-core/src/com/arsdigita/portation/Marshaller.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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; - -import org.apache.log4j.Logger; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Central class for exporting and importing objects of this system stored in - * the database. - * - * Exporting or importing object classes need to implement - * interface identifiable. - * - * @author Tobias Osmers - * @version created on 03.02.2016 - */ -public class Marshaller { - private static final Logger log = Logger.getLogger(Marshaller.class); - - // Assigns lists with objects of the same type as values to their typ as - // key. - private Map, List> classListMap = new HashMap<>(); - - - /** - * Main exportUsers method. Organizes the objects into list of the same type - * and calls a second exportUsers method for each list. - * - * @param objects All objects to be exported - * @param format The exportUsers style/format e.g. CSV or JSON - * @param filename The name of the file to be exported to - */ - public void exportObjects(List objects, Format format, - String filename) { - putObjects(objects); - - for (Map.Entry, List> - classListEntry : classListMap.entrySet()) { - - exportList(classListEntry.getValue(), classListEntry.getKey(), - format, filename); - } - } - - /** - * Organizes a list of different {@link Portable} objects into a map - * assigning lists of the same type to their type as values to a key. The - * type which all objects of that list have in common is their key. - * That opens the possibility of being certain of the objects types in - * the list. Guarantied through this implementation. - * - * @param objects list of all objects being organized - */ - private void putObjects(List objects) { - for (Portable object : objects) { - Class type = object.getClass(); - - if (classListMap.containsKey(type)) { - classListMap.get(type).add(object); - } else { - List values = new ArrayList<>(); - values.add(object); - classListMap.put(type, values); - } - } - } - - /** - * Selects the right marshaller for the given type, initializes that - * marshaller for the given exportUsers wishes and calls the exportUsers method of - * that marshaller upon the given list of same typed objects. - * - * Naming convention for the exportUsers file name: - * __. - * - * @param list List of objects to be exported of the same type - * @param type The class of the type - * @param format The exportUsers style - * @param filename The filename - * @param

The type of the current marshaller - */ - private

void exportList(List

list, Class type, Format format, String filename) { - @SuppressWarnings("unchecked") - AbstractMarshaller

marshaller = (AbstractMarshaller

) list.get - (0).getMarshaller(); - - marshaller.prepare(format, filename + "__" + type.toString(), - false); - marshaller.exportList(list); - } - -} - diff --git a/ccm-core/src/com/arsdigita/portation/cmd/CoreExporter.java b/ccm-core/src/com/arsdigita/portation/cmd/CoreExporter.java deleted file mode 100644 index cb185f1a6..000000000 --- a/ccm-core/src/com/arsdigita/portation/cmd/CoreExporter.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.Format; -import com.arsdigita.portation.conversion.NgCollection; -import com.arsdigita.portation.modules.core.categorization.CategorizationMarshaller; -import com.arsdigita.portation.modules.core.categorization.CategoryMarshaller; -import com.arsdigita.portation.modules.core.security.GroupMarshaller; -import com.arsdigita.portation.modules.core.security.GroupMembershipMarshaller; -import com.arsdigita.portation.modules.core.security.PermissionMarshaller; -import com.arsdigita.portation.modules.core.security.RoleMarshaller; -import com.arsdigita.portation.modules.core.security.RoleMembershipMarshaller; -import com.arsdigita.portation.modules.core.security.UserMarshaller; -import com.arsdigita.portation.modules.core.workflow.TaskAssignmentMarshaller; -import com.arsdigita.portation.modules.core.workflow.AssignableTaskMarshaller; -import com.arsdigita.portation.modules.core.workflow.WorkflowMarshaller; -import com.arsdigita.portation.modules.core.workflow.WorkflowTemplateMarshaller; - -import java.util.ArrayList; - -/** - * Helper to implement the specifics for the exportation. Makes source code - * in the cli-tool shorter and more readable. - * - * @author ( - NgCollection.users.values())); - System.out.printf("\t\tdone.\n"); - } - - static void exportGroups() { - System.out.printf("\tExporting groups..."); - GroupMarshaller groupMarshaller = new GroupMarshaller(); - groupMarshaller.prepare(Format.XML, pathName, - "groups", indentation); - groupMarshaller.exportList(new ArrayList<>( - NgCollection.groups.values())); - System.out.printf("\t\tdone.\n"); - } - - static void exportGroupMemberships() { - System.out.printf("\tExporting group memberships..."); - GroupMembershipMarshaller groupMembershipMarshaller = new - GroupMembershipMarshaller(); - groupMembershipMarshaller.prepare(Format.XML, pathName, - "groupMemberships", indentation); - groupMembershipMarshaller.exportList(new ArrayList<>( - NgCollection.groupMemberships.values())); - System.out.printf("\tdone.\n"); - } - - static void exportRoles() { - System.out.printf("\tExporting roles..."); - RoleMarshaller roleMarshaller = new RoleMarshaller(); - roleMarshaller.prepare(Format.XML, pathName, - "roles", indentation); - roleMarshaller.exportList(new ArrayList<>(NgCollection - .roles.values())); - System.out.printf("\t\tdone.\n"); - } - - static void exportRoleMemberships() { - System.out.printf("\tExporting role memberships..."); - RoleMembershipMarshaller roleMembershipMarshaller = new - RoleMembershipMarshaller(); - roleMembershipMarshaller.prepare(Format.XML, pathName, - "roleMemberships", indentation); - roleMembershipMarshaller.exportList(new ArrayList<> - (NgCollection.roleMemberships.values())); - System.out.printf("\tdone.\n"); - } - - static void exportCategories() { - System.out.printf("\tExporting categories..."); - CategoryMarshaller categoryMarshaller = new - CategoryMarshaller(); - categoryMarshaller.prepare(Format.XML, pathName, - "categories", indentation); - categoryMarshaller.exportList(NgCollection.sortedCategories); - System.out.printf("\t\tdone.\n"); - } - - static void exportCategorizations() { - System.out.printf("\tExporting categorizations..."); - CategorizationMarshaller categorizationMarshaller = new - CategorizationMarshaller(); - categorizationMarshaller.prepare(Format.XML, pathName, - "categorizations", indentation); - categorizationMarshaller.exportList(new ArrayList<>( - NgCollection.categorizations.values())); - System.out.printf("\tdone.\n"); - } - - static void exportWorkflowTemplates() { - System.out.printf("\tExporting workflow templates..."); - WorkflowTemplateMarshaller workflowTemplateMarshaller = new - WorkflowTemplateMarshaller(); - workflowTemplateMarshaller.prepare(Format.XML, pathName, - "workflowTemplates", indentation); - workflowTemplateMarshaller.exportList(new ArrayList<>(NgCollection - .workflowTemplates.values())); - System.out.printf("\tdone.\n"); - } - - static void exportWorkflows() { - System.out.printf("\tExporting workflows..."); - WorkflowMarshaller workflowMarshaller = new - WorkflowMarshaller(); - workflowMarshaller.prepare(Format.XML, pathName, - "workflows", indentation); - workflowMarshaller.exportList(new ArrayList<> - (NgCollection.workflows.values())); - System.out.printf("\t\tdone.\n"); - } - - static void exportAssignableTasks() { - System.out.printf("\tExporting assignable tasks..."); - AssignableTaskMarshaller assignableTaskMarshaller = new - AssignableTaskMarshaller(); - assignableTaskMarshaller.prepare(Format.XML, pathName, - "assignableTasks", indentation); - assignableTaskMarshaller.exportList(new ArrayList<> - (NgCollection.assignableTasks.values())); - System.out.printf("\tdone.\n"); - } - - static void exportTaskAssignments() { - System.out.printf("\tExporting task assignments..."); - TaskAssignmentMarshaller taskAssignmentMarshaller = new - TaskAssignmentMarshaller(); - taskAssignmentMarshaller.prepare(Format.XML, pathName, - "taskAssignments", indentation); - taskAssignmentMarshaller.exportList(new ArrayList<> - (NgCollection.taskAssignments.values())); - System.out.printf("\tdone.\n"); - } - - static void exportPermissions() { - System.out.printf("\tExporting permissions..."); - PermissionMarshaller permissionMarshaller = new - PermissionMarshaller(); - permissionMarshaller.prepare(Format.XML, pathName, - "permissions", indentation); - permissionMarshaller.exportList(new ArrayList<> - (NgCollection.permissions.values())); - System.out.printf("\tdone.\n"); - } -} diff --git a/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java b/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java index 45fab707a..e51141607 100644 --- a/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java +++ b/ccm-core/src/com/arsdigita/portation/cmd/ExportCliTool.java @@ -19,10 +19,13 @@ package com.arsdigita.portation.cmd; import com.arsdigita.portation.conversion.CoreConverter; +import com.arsdigita.portation.modules.CoreExporter; 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 * one or many specified file types. @@ -83,20 +86,47 @@ public class ExportCliTool extends Program { printUsage(); break; - case "export": - export(args); - break; - case "convert": convert(); break; + case "export": + export(args); + break; + default: printUsage(); break; } } + /** + * Method for converting all trunk objects into ng objects at once. + */ + private void convert() { + try { + System.err.println("Started conversions of systems objects to " + + "ng-objects..."); + + CoreConverter.getInstance().startConversionToNg(); + + Class cls = Class + .forName("com.arsdigita.london.terms.portation" + + ".conversion.LdnTermsConverter"); + if (cls != null) { + Method method = cls.getMethod("startConversionToNg"); + method.invoke(cls.newInstance()); + } + + System.err.println("Finished conversions."); + System.out.printf("\n"); + } catch (Exception e) { + logger.error("ERROR while converting trunk-objects to " + + "ng-objects", e); + e.printStackTrace(); + } + } + /** * Method defining the process of exporting after its command has been * triggered. @@ -119,16 +149,6 @@ public class ExportCliTool extends Program { try { switch (moduleClass) { - case "categories": - convert(); - CoreExporter.exportCategories(); - break; - - case "categorizations": - convert(); - CoreExporter.exportCategorizations(); - break; - case "users": convert(); CoreExporter.exportUsers(); @@ -154,6 +174,16 @@ public class ExportCliTool extends Program { CoreExporter.exportRoleMemberships(); break; + case "categories": + convert(); + CoreExporter.exportCategories(); + break; + + case "categorizations": + convert(); + CoreExporter.exportCategorizations(); + break; + case "workflowTemplates": convert(); CoreExporter.exportWorkflowTemplates(); @@ -179,16 +209,16 @@ public class ExportCliTool extends Program { CoreExporter.exportPermissions(); break; - case "all_core": + default: convert(); System.out.println("Started exporting all ng-objects..."); - CoreExporter.exportCategories(); - CoreExporter.exportCategorizations(); CoreExporter.exportUsers(); CoreExporter.exportGroups(); CoreExporter.exportGroupMemberships(); CoreExporter.exportRoles(); CoreExporter.exportRoleMemberships(); + CoreExporter.exportCategories(); + CoreExporter.exportCategorizations(); CoreExporter.exportWorkflows(); CoreExporter.exportWorkflowTemplates(); CoreExporter.exportAssignableTasks(); @@ -198,31 +228,12 @@ public class ExportCliTool extends Program { System.out.printf("\n"); break; - default: - printUsage(); - break; } } catch (Exception ex) { logger.error("ERROR while exporting", ex); } } - /** - * Method for converting all trunk objects into ng objects at once. - */ - private void convert() { - try { - System.err.println("Started conversions of systems objects to " + - "ng-objects..."); - CoreConverter.startConversionToNg(); - System.err.println("Finished conversions."); - System.out.printf("\n"); - } catch (Exception e) { - logger.error("ERROR while converting trunk-objects to " + - "ng-objects", e); - } - } - /** @@ -238,6 +249,8 @@ public class ExportCliTool extends Program { "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 " + "\t\t Exports the chosen module class to a file\n" + "\t\t\t\t" + @@ -258,7 +271,7 @@ public class ExportCliTool extends Program { " \t\t taskAssignments \t\t all taskAssignments of the system\n" + " \t\t permissions \t\t all permissions of the system\n" + " \n" + - " \t\t all_core \t\t all objects of the entire core module" + + " \t\t default: \t\t all objects of the entire core module" + "\n" + "\n" + "" + diff --git a/ccm-core/src/com/arsdigita/portation/conversion/CoreConverter.java b/ccm-core/src/com/arsdigita/portation/conversion/CoreConverter.java index 8865cb262..d4a50c141 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/CoreConverter.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/CoreConverter.java @@ -18,6 +18,7 @@ */ package com.arsdigita.portation.conversion; +import com.arsdigita.portation.AbstractConverter; import com.arsdigita.portation.conversion.core.categorization.CategoryConversion; import com.arsdigita.portation.conversion.core.security.GroupConversion; import com.arsdigita.portation.conversion.core.security.PermissionConversion; @@ -25,7 +26,6 @@ import com.arsdigita.portation.conversion.core.security.RoleConversion; import com.arsdigita.portation.conversion.core.security.UserConversion; import com.arsdigita.portation.conversion.core.workflow.AssignableTaskConversion; import com.arsdigita.portation.conversion.core.workflow.WorkflowConversion; -import com.arsdigita.portation.modules.core.categorization.Category; import com.arsdigita.portation.modules.core.security.Permission; @@ -33,41 +33,47 @@ import com.arsdigita.portation.modules.core.security.Permission; * This core converter class calls all the conversions from trunk-objects * to ng-objects in a specific order to guarantee a correct dependency * recreation in the ng-objects. All the created objects are going to be - * stored in maps as -pairs in the {@link NgCollection}-class. + * stored in maps as -pairs in the {@link NgCoreCollection}-class. * * @author roles = new ArrayList<>(NgCollection.roles.values()); + List roles = new ArrayList<>(NgCoreCollection.roles.values()); for (Role role : roles) { if (role.getName().equals(roleName)) return role; diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java index 3fbece5ee..5f19280bf 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/security/RoleConversion.java @@ -20,7 +20,7 @@ package com.arsdigita.portation.conversion.core.security; import com.arsdigita.kernel.PartyCollection; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.Party; import com.arsdigita.portation.modules.core.security.Role; import com.arsdigita.portation.modules.core.security.RoleMembership; @@ -94,7 +94,7 @@ public class RoleConversion { long processed = 0; while (partyCollection.next()) { - Party member = NgCollection.parties.get(partyCollection.getParty() + Party member = NgCoreCollection.parties.get(partyCollection.getParty() .getID().longValue()); if (role != null && member != null) { diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java index 508e7e2e7..f4927a84b 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/AssignableTaskConversion.java @@ -21,7 +21,7 @@ package com.arsdigita.portation.conversion.core.workflow; import com.arsdigita.kernel.GroupCollection; import com.arsdigita.kernel.RoleCollection; -import com.arsdigita.portation.conversion.NgCollection; +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; @@ -88,7 +88,7 @@ public class AssignableTaskConversion { try { userTaskWorkflow = trunkUserTask.getWorkflow(); if (userTaskWorkflow != null) { - Workflow workflow = NgCollection.workflows.get( + Workflow workflow = NgCoreCollection.workflows.get( userTaskWorkflow.getID().longValue()); if (workflow != null) { assignableTask.setWorkflow(workflow); @@ -104,7 +104,7 @@ public class AssignableTaskConversion { .arsdigita.workflow.simple.TaskComment) commentsIt.next(); TaskComment taskComment = new TaskComment(trunkTaskComment); - User author = NgCollection.users.get( + User author = NgCoreCollection.users.get( trunkTaskComment.getUser().getID().longValue()); taskComment.setAuthor(author); @@ -114,14 +114,14 @@ public class AssignableTaskConversion { // set lockingUser and notificationSender if (trunkUserTask.getLockedUser() != null) { - User lockingUser = NgCollection.users.get(trunkUserTask + User lockingUser = NgCoreCollection.users.get(trunkUserTask .getLockedUser() .getID().longValue()); if (lockingUser != null) assignableTask.setLockingUser(lockingUser); } if (trunkUserTask.getNotificationSender() != null) { - User notificationSender = NgCollection.users.get(trunkUserTask + User notificationSender = NgCoreCollection.users.get(trunkUserTask .getNotificationSender().getID().longValue()); if (notificationSender != null) assignableTask.setNotificationSender(notificationSender); @@ -159,7 +159,7 @@ public class AssignableTaskConversion { while (groupCollection.next()) { RoleCollection roleCollection = groupCollection.getGroup().getRoles(); while (roleCollection.next()) { - Role role = NgCollection.roles.get(roleCollection.getRole() + Role role = NgCoreCollection.roles.get(roleCollection.getRole() .getID().longValue()); if (assignableTask != null && role != null) { @@ -195,12 +195,12 @@ public class AssignableTaskConversion { for (com.arsdigita.workflow.simple.UserTask trunkUserTask : trunkUserTasks) { - AssignableTask assignableTask = NgCollection.assignableTasks.get(trunkUserTask.getID() + AssignableTask assignableTask = NgCoreCollection.assignableTasks.get(trunkUserTask.getID() .longValue()); Iterator it = trunkUserTask.getDependencies(); while (it.hasNext()) { - AssignableTask dependency = NgCollection.assignableTasks.get(((Task) it + AssignableTask dependency = NgCoreCollection.assignableTasks.get(((Task) it .next()) .getID().longValue()); diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java index 93d9669d4..78147f7e9 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java @@ -19,7 +19,7 @@ package com.arsdigita.portation.conversion.core.workflow; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.workflow.Workflow; import com.arsdigita.portation.modules.core.workflow.WorkflowTemplate; @@ -59,7 +59,6 @@ public class WorkflowConversion { for (com.arsdigita.workflow.simple.Workflow trunkWorkflow : trunkWorkflows) { - // create workflows Workflow workflow = new Workflow(trunkWorkflow, false); @@ -67,7 +66,7 @@ public class WorkflowConversion { com.arsdigita.workflow.simple.WorkflowTemplate trunkWorkflowTemplate = trunkWorkflow.getWorkflowTemplate(); if (trunkWorkflowTemplate != null) { - WorkflowTemplate workflowTemplate = NgCollection + WorkflowTemplate workflowTemplate = NgCoreCollection .workflowTemplates.get(trunkWorkflowTemplate.getID() .longValue()); workflow.setTemplate(workflowTemplate); @@ -76,7 +75,7 @@ public class WorkflowConversion { // set object association ACSObject trunkObject = trunkWorkflow.getObject(); if (trunkObject != null) { - CcmObject object = NgCollection.ccmObjects.get(trunkObject + CcmObject object = NgCoreCollection.ccmObjects.get(trunkObject .getID().longValue()); workflow.setObject(object); } diff --git a/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java b/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java new file mode 100644 index 000000000..15fe6f4fa --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/CoreExporter.java @@ -0,0 +1,176 @@ +/* + * 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.modules; + +import com.arsdigita.portation.AbstractExporter; +import com.arsdigita.portation.Format; +import com.arsdigita.portation.conversion.NgCoreCollection; +import com.arsdigita.portation.modules.core.categorization.CategorizationMarshaller; +import com.arsdigita.portation.modules.core.categorization.CategoryMarshaller; +import com.arsdigita.portation.modules.core.security.*; +import com.arsdigita.portation.modules.core.workflow.AssignableTaskMarshaller; +import com.arsdigita.portation.modules.core.workflow.TaskAssignmentMarshaller; +import com.arsdigita.portation.modules.core.workflow.WorkflowMarshaller; +import com.arsdigita.portation.modules.core.workflow.WorkflowTemplateMarshaller; + +import java.util.ArrayList; + +/** + * Helper to implement the specifics for the exportation. Makes source code + * in the cli-tool shorter and more readable. + * + * @author (NgCoreCollection.users.values())); + System.out.printf("\t\tdone.\n"); + } + + public 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"); + } + + public 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"); + } + + public 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"); + } + + public 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"); + } + + public 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"); + } + + public 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"); + } + + public static void exportWorkflowTemplates() { + System.out.printf("\tExporting workflow templates..."); + WorkflowTemplateMarshaller workflowTemplateMarshaller = new + WorkflowTemplateMarshaller(); + workflowTemplateMarshaller + .prepare(Format.XML, pathName, "workflowTemplates", + indentation); + workflowTemplateMarshaller + .exportList(new ArrayList<>(NgCoreCollection.workflowTemplates + .values())); + System.out.printf("\tdone.\n"); + } + + public static void exportWorkflows() { + System.out.printf("\tExporting workflows..."); + WorkflowMarshaller workflowMarshaller = new WorkflowMarshaller(); + workflowMarshaller + .prepare(Format.XML, pathName, "workflows", indentation); + workflowMarshaller + .exportList(new ArrayList<>(NgCoreCollection.workflows.values())); + System.out.printf("\t\tdone.\n"); + } + + public static void exportAssignableTasks() { + System.out.printf("\tExporting assignable tasks..."); + AssignableTaskMarshaller assignableTaskMarshaller = new + AssignableTaskMarshaller(); + assignableTaskMarshaller + .prepare(Format.XML, pathName, "assignableTasks", indentation); + assignableTaskMarshaller + .exportList(new ArrayList<>(NgCoreCollection.assignableTasks + .values())); + System.out.printf("\tdone.\n"); + } + + public 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"); + } + + public 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"); + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java index f4061baa7..ad29aa9c8 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Categorization.java @@ -19,9 +19,8 @@ package com.arsdigita.portation.modules.core.categorization; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.core.CcmObject; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIdentityReference; @@ -62,15 +61,10 @@ public class Categorization implements Portable { this.type = ""; - NgCollection.categorizations.put(this.categorizationId, this); + NgCoreCollection.categorizations.put(this.categorizationId, this); } - @Override - public AbstractMarshaller getMarshaller() { - return new CategorizationMarshaller(); - } - public long getCategorizationId() { return categorizationId; } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java index 28eeb1210..86fce8560 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java @@ -20,9 +20,8 @@ package com.arsdigita.portation.modules.core.categorization; import com.arsdigita.categorization.CategoryLocalization; import com.arsdigita.categorization.CategoryLocalizationCollection; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.fasterxml.jackson.annotation.JsonIdentityInfo; @@ -107,15 +106,10 @@ public class Category extends CcmObject implements Portable { ? defaultParent.getNumberOfChildCategories() + 1 : 0; - NgCollection.categories.put(this.getObjectId(), this); + NgCoreCollection.categories.put(this.getObjectId(), this); } - @Override - public AbstractMarshaller getMarshaller() { - return new CategoryMarshaller(); - } - public String getUniqueId() { return uniqueId; } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java b/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java index 877928a75..dec3f39c3 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java @@ -19,7 +19,7 @@ package com.arsdigita.portation.modules.core.core; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.categorization.Categorization; import com.arsdigita.portation.modules.core.categorization.Category; import com.arsdigita.portation.modules.core.security.Permission; @@ -71,9 +71,22 @@ public class CcmObject { this.permissions = new ArrayList<>(); this.categories = new ArrayList<>(); - NgCollection.ccmObjects.put(this.objectId, this); + NgCoreCollection.ccmObjects.put(this.objectId, this); } + public CcmObject() {} + /*public CcmObject(final Domain trunkDomain) { + this.objectId = ACSObject.generateID().longValue(); + + this.uuid = UUID.randomUUID().toString(); + this.displayName = trunkDomain.getKey() + "_DName"; + + this.permissions = new ArrayList<>(); + this.categories = new ArrayList<>(); + + NgCoreCollection.ccmObjects.put(this.objectId, this); + }*/ + public long getObjectId() { return objectId; } diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/l10n/LocalizedString.java b/ccm-core/src/com/arsdigita/portation/modules/core/l10n/LocalizedString.java index 4412761ba..e8790d22d 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/l10n/LocalizedString.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/l10n/LocalizedString.java @@ -20,11 +20,7 @@ package com.arsdigita.portation.modules.core.l10n; import com.fasterxml.jackson.annotation.JsonIgnore; -import java.util.Collections; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * A helper class for localisable string properties. This class is declared as diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java index 46d09875e..704eebd32 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/Group.java @@ -18,9 +18,8 @@ */ package com.arsdigita.portation.modules.core.security; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.ObjectIdGenerators; @@ -45,13 +44,9 @@ public class Group extends Party implements Portable { super(trunkGroup); this.memberships = new HashSet<>(); - NgCollection.groups.put(this.getPartyId(), this); + NgCoreCollection.groups.put(this.getPartyId(), this); } - @Override - public AbstractMarshaller getMarshaller() { - return new GroupMarshaller(); - } public Set getMemberships() { return memberships; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java index 46257dce8..3bc090cf4 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupMembership.java @@ -19,9 +19,8 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIdentityReference; @@ -45,13 +44,9 @@ public class GroupMembership implements Portable { this.group = group; this.member = member; - NgCollection.groupMemberships.put(this.membershipId, this); + NgCoreCollection.groupMemberships.put(this.membershipId, this); } - @Override - public AbstractMarshaller getMarshaller() { - return new GroupMembershipMarshaller(); - } public long getMembershipId() { return membershipId; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/Party.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/Party.java index bac32d7d0..823d8cfcf 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/Party.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/Party.java @@ -18,7 +18,7 @@ */ package com.arsdigita.portation.modules.core.security; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.ObjectIdGenerators; @@ -51,7 +51,7 @@ public class Party { this.roleMemberships = new HashSet<>(); - NgCollection.parties.put(this.partyId, this); + NgCoreCollection.parties.put(this.partyId, this); } public long getPartyId() { diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java index 2f31cf07a..d0a51e8a5 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/Permission.java @@ -19,9 +19,8 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.security.util.PermissionIdMapper; import com.fasterxml.jackson.annotation.JsonIdentityInfo; @@ -62,7 +61,7 @@ public class Permission implements Portable { this.creationDate = trunkPermission.getCreationDate(); this.creationIp = trunkPermission.getCreationIP(); - NgCollection.permissions.put(this.permissionId, this); + NgCoreCollection.permissions.put(this.permissionId, this); } /** @@ -108,14 +107,10 @@ public class Permission implements Portable { this.creationDate = ngPermission.getCreationDate(); this.creationIp = ngPermission.getCreationIp(); - NgCollection.permissions.put(this.permissionId, this); + NgCoreCollection.permissions.put(this.permissionId, this); } - @Override - public AbstractMarshaller getMarshaller() { - return new PermissionMarshaller(); - } public long getPermissionId() { return permissionId; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/Role.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/Role.java index 9a300077a..7dc08743e 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/security/Role.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/Role.java @@ -19,20 +19,15 @@ package com.arsdigita.portation.modules.core.security; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.workflow.TaskAssignment; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.ObjectIdGenerators; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; +import java.util.*; /** * @author Tobias Osmers<\a> @@ -72,13 +67,9 @@ public class User extends Party implements Portable { this.groupMemberships = new HashSet<>(); - NgCollection.users.put(this.getPartyId(), this); + NgCoreCollection.users.put(this.getPartyId(), this); } - @Override - public AbstractMarshaller getMarshaller() { - return new UserMarshaller(); - } public String getGivenName() { return givenName; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java index 12bd4919b..4ed3ad1c4 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/AssignableTask.java @@ -18,9 +18,8 @@ */ package com.arsdigita.portation.modules.core.workflow; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.User; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -64,13 +63,9 @@ public class AssignableTask extends Task implements Portable { this.assignments = new ArrayList<>(); - NgCollection.assignableTasks.put(this.getTaskId(), this); + NgCoreCollection.assignableTasks.put(this.getTaskId(), this); } - @Override - public AbstractMarshaller getMarshaller() { - return new AssignableTaskMarshaller(); - } public boolean isLocked() { return locked; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java index 6eb6fb6c7..b57197bc0 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Task.java @@ -18,7 +18,7 @@ */ package com.arsdigita.portation.modules.core.workflow; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.workflow.util.StateMapper; import com.fasterxml.jackson.annotation.JsonIdentityInfo; @@ -73,7 +73,7 @@ public class Task { this.dependsOn = new ArrayList<>(); this.comments = new ArrayList<>(); - NgCollection.tasks.put(this.getTaskId(), this); + NgCoreCollection.tasks.put(this.getTaskId(), this); } public long getTaskId() { diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java index bcdba4488..3fb3a7476 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignment.java @@ -19,9 +19,8 @@ package com.arsdigita.portation.modules.core.workflow; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.security.Role; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIdentityReference; @@ -47,13 +46,9 @@ public class TaskAssignment implements Portable { this.task = task; this.role = role; - NgCollection.taskAssignments.put(this.taskAssignmentId, this); + NgCoreCollection.taskAssignments.put(this.taskAssignmentId, this); } - @Override - public AbstractMarshaller getMarshaller() { - return new TaskAssignmentMarshaller(); - } public long getTaskAssignmentId() { return taskAssignmentId; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java index b428c29f9..3e7cf1c64 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/Workflow.java @@ -18,9 +18,8 @@ */ package com.arsdigita.portation.modules.core.workflow; -import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.Portable; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.workflow.util.StateMapper; @@ -60,7 +59,7 @@ public class Workflow implements Portable { this.workflowId = trunkWorkFlow.getID().longValue(); this.uuid = UUID.randomUUID().toString(); - //template + //this.template this.name = new LocalizedString(); this.name.addValue(Locale.getDefault(), trunkWorkFlow.getDisplayName()); @@ -73,18 +72,14 @@ public class Workflow implements Portable { this.active = trunkWorkFlow.isActive(); this.tasksState = StateMapper.mapTaskState(trunkWorkFlow.getState()); - //object + //this.object this.tasks = new ArrayList<>(); if (!template) - NgCollection.workflows.put(this.workflowId, this); + NgCoreCollection.workflows.put(this.workflowId, this); } - @Override - public AbstractMarshaller getMarshaller() { - return new WorkflowMarshaller(); - } public long getWorkflowId() { return workflowId; diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplate.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplate.java index 23f4dda71..957c54482 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplate.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/WorkflowTemplate.java @@ -18,7 +18,7 @@ */ package com.arsdigita.portation.modules.core.workflow; -import com.arsdigita.portation.conversion.NgCollection; +import com.arsdigita.portation.conversion.NgCoreCollection; /** * @author getAllObjectDomains() { + List domainList = new ArrayList<>(); + + final Session session = SessionManager.getSession(); + DomainCollection collection = new DomainCollection(session.retrieve( + Domain.BASE_DATA_OBJECT_TYPE)); + + while (collection.next()) { + Domain domain = (Domain) collection.getDomainObject(); + if (domain != null) { + domainList.add(domain); + } + } + + collection.close(); + return domainList; + } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/LdnTermsConverter.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/LdnTermsConverter.java new file mode 100644 index 000000000..67b10fbd6 --- /dev/null +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/LdnTermsConverter.java @@ -0,0 +1,59 @@ +/* + * 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.london.terms.portation.conversion; + +import com.arsdigita.london.terms.portation.conversion.core.categorization.DomainConversion; +import com.arsdigita.portation.AbstractConverter; + +/** + * This core converter class calls all the conversions from trunk-objects + * to ng-objects in a specific order to guarantee a correct dependency + * recreation in the ng-objects. All the created objects are going to be + * stored in maps as -pairs in the {@link NgCoreCollection}-class. + * + * @author Tobias Osmers<\a> + * @version created the 7/28/17 + */ +public class NgCoreCollection { + public static Map domains = new HashMap<>(); + + /** + * Private constructor to prevent the instantiation of this class. + */ + private NgCoreCollection() {} +} diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/categorization/DomainConversion.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/categorization/DomainConversion.java new file mode 100644 index 000000000..ef4d309cc --- /dev/null +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/conversion/core/categorization/DomainConversion.java @@ -0,0 +1,79 @@ +/* + * 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.london.terms.portation.conversion.core.categorization; + +import com.arsdigita.london.terms.portation.modules.core.categorization.Domain; +import com.arsdigita.portation.conversion.NgCoreCollection; +import com.arsdigita.portation.modules.core.categorization.Category; + +import java.util.List; + +/** + * Class for converting all trunk-{@link com.arsdigita.london.terms.Domain}s + * into ng-{@link Domain}s as preparation for a successful export of all trunk + * classes into the new ng-system. + * + * @author trunkDomains = com + .arsdigita.london.terms.Domain.getAllObjectDomains(); + System.err.println("done."); + + System.err.printf("\tConverting domains...\n"); + createDomainsAndSetAssociations(trunkDomains); + System.err.printf("\tdone.\n"); + } + + private static void createDomainsAndSetAssociations( + List trunkDomains) { + long processed = 0; + + for(com.arsdigita.london.terms.Domain trunkDomain : trunkDomains) { + // create domains + Domain domain = new Domain(trunkDomain); + + // set root (category) association + com.arsdigita.categorization.Category model = trunkDomain + .getModel(); + if (model != null) { + Category root = NgCoreCollection + .categories + .get(model.getID().longValue()); + domain.setRoot(root); + } + + processed++; + } + + System.err.printf("\t\tCreated %d domains.\n", processed); + } + + +} diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java new file mode 100644 index 000000000..0cfc01908 --- /dev/null +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/LdnTermsExporter.java @@ -0,0 +1,47 @@ +/* + * 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.london.terms.portation.modules; + +import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; +import com.arsdigita.london.terms.portation.modules.core.categorization.DomainMarshaller; +import com.arsdigita.portation.AbstractExporter; +import com.arsdigita.portation.Format; + +import java.util.ArrayList; + +/** + * Helper to implement the specifics for the exportation. Makes source code + * in the cli-tool shorter and more readable. + * + * @author (NgCoreCollection.domains.values())); + System.out.printf("\t\tdone.\n"); + } + +} diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/Domain.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/Domain.java new file mode 100644 index 000000000..9929c6b19 --- /dev/null +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/categorization/Domain.java @@ -0,0 +1,145 @@ +/* + * 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.london.terms.portation.modules.core.categorization; + +import com.arsdigita.london.terms.portation.conversion.NgCoreCollection; +import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication; +import com.arsdigita.portation.Portable; +import com.arsdigita.portation.modules.core.categorization.Category; +import com.arsdigita.portation.modules.core.core.CcmObject; +import com.arsdigita.portation.modules.core.l10n.LocalizedString; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +/** + * A domain is collection of categories designed a specific purpose. This entity + * replaces the {@code Domain} entity from the old + * {@link com.arsdigita.london.terms.Domain} module as well as the {@code + * CategoryPurpose} entity from the old {@code ccm-core module}. + * + * A {@code Domain} can be mapped to multiple {@link CcmApplication}s. Normally + * This is used to make a {@code Domain} available in the application. The + * {@link CcmApplication}s to which a {@code Domain} is mapped are called + * owners of the domain. + * + * @author Tobias Osmers - * @version created on 5/9/16 + * @author Tobias Osmers<\a> + * @version created the 7/27/17 + */ +public class DomainOwnership { + + private long ownershipId; + private CcmApplication owner; + private Domain domain; + private String context; + private long ownerOrder; + private long domainOrder; + + + public long getOwnershipId() { + return ownershipId; + } + + public void setOwnershipId(final long ownershipId) { + this.ownershipId = ownershipId; + } + + public CcmApplication getOwner() { + return owner; + } + + public void setOwner(final CcmApplication owner) { + this.owner = owner; + } + + public Domain getDomain() { + return domain; + } + + public void setDomain(final Domain domain) { + this.domain = domain; + } + + public String getContext() { + return context; + } + + public void setContext(final String context) { + this.context = context; + } + + public long getOwnerOrder() { + return ownerOrder; + } + + public void setOwnerOrder(final long ownerOrder) { + this.ownerOrder = ownerOrder; + } + + public long getDomainOrder() { + return domainOrder; + } + + public void setDomainOrder(final long domainOrder) { + this.domainOrder = domainOrder; + } +} diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/Resource.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/Resource.java new file mode 100644 index 000000000..98443b402 --- /dev/null +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/core/Resource.java @@ -0,0 +1,105 @@ +/* + * 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.london.terms.portation.modules.core.core; + +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication; +import com.arsdigita.portation.modules.core.core.CcmObject; +import com.arsdigita.portation.modules.core.l10n.LocalizedString; + +import java.util.Date; +import java.util.List; + +/** + * The {@code Resource} class is a base class for several other classes, for + * example the {@link CcmApplication} class. + * + * Resources can be nested, a resource can have multiple child resources. + * + * This class is an adopted variant of the class + * {@code com.arsdigita.kernel.Resource} from the old structure. This class is + * maybe removed in future releases. Therefore it is strictly recommend not to + * use this class directly. + * + * @author Tobias Osmers<\a> + * @version created the 7/27/17 + */ +public class ResourceType { + + private long resourceTypeId; + private String title; + private LocalizedString description; + private boolean workspaceApplication; + private boolean viewableAsFullPage; + private boolean viewableAsEmbedded; + private boolean singleton; + + + public long getResourceTypeId() { + return resourceTypeId; + } + + public void setResourceTypeId(final long resourceTypeId) { + this.resourceTypeId = resourceTypeId; + } + + public String getTitle() { + return title; + } + + public void setTitle(final String title) { + this.title = title; + } + + public LocalizedString getDescription() { + return description; + } + + public void setDescription(final LocalizedString description) { + this.description = description; + } + + public boolean isWorkspaceApplication() { + return workspaceApplication; + } + + public void setWorkspaceApplication(final boolean workspaceApplication) { + this.workspaceApplication = workspaceApplication; + } + + public boolean isViewableAsFullPage() { + return viewableAsFullPage; + } + + public void setViewableAsFullPage(final boolean viewableAsFullPage) { + this.viewableAsFullPage = viewableAsFullPage; + } + + public boolean isViewableAsEmbedded() { + return viewableAsEmbedded; + } + + public void setViewableAsEmbedded(final boolean viewableAsEmbedded) { + this.viewableAsEmbedded = viewableAsEmbedded; + } + + public boolean isSingleton() { + return singleton; + } + + public void setSingleton(final boolean singleton) { + this.singleton = singleton; + } +} diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplication.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplication.java new file mode 100644 index 000000000..1696c7c70 --- /dev/null +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/portation/modules/core/web/CcmApplication.java @@ -0,0 +1,66 @@ +/* + * 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.london.terms.portation.modules.core.web; + +import com.arsdigita.kernel.ACSObject; +import com.arsdigita.london.terms.portation.modules.core.categorization.DomainOwnership; +import com.arsdigita.london.terms.portation.modules.core.core.Resource; + +import java.util.List; + +/** + * @author