[TRUNK][FEATURE]

- adds funktionalaty to convert trunks domain-, resourceType- and application-objects to their ng's counterparts
- adds funktionality to export converted domains, resourceTypes and ccmApplications

git-svn-id: https://svn.libreccm.org/ccm/trunk@4895 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2017-08-03 14:29:33 +00:00
parent 04ef1ba2df
commit 1b40547cb0
26 changed files with 776 additions and 202 deletions

View File

@ -19,28 +19,19 @@
package com.arsdigita.kernel;
import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.kernel.ui.ResourceConfigFormSection;
import com.arsdigita.kernel.ui.ResourceConfigComponent;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.DataAssociationCursor;
import com.arsdigita.persistence.PersistenceException;
import com.arsdigita.db.Sequences;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.kernel.ui.ResourceConfigComponent;
import com.arsdigita.kernel.ui.ResourceConfigFormSection;
import com.arsdigita.persistence.*;
import com.arsdigita.util.Assert;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
import java.util.Collection;
import org.apache.log4j.Logger;
import java.math.BigDecimal;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import java.util.*;
/**
* XXX JAVADOC XXX
@ -431,4 +422,27 @@ public class ResourceType extends DomainObject {
return getConfig().getModifyComponent(resource);
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all resource types
*/
public static List<ResourceType> getAllObjectResourceTypes() {
List<ResourceType> resourceTypeList = new ArrayList<>();
ResourceTypeCollection collection = ResourceType
.retrieveAllResourceTypes();
while (collection.next()) {
ResourceType resourceType = (ResourceType) collection.getDomainObject();
if (resourceType != null) {
resourceTypeList.add(resourceType);
}
}
collection.close();
return resourceTypeList;
}
}

View File

@ -0,0 +1,28 @@
/*
* 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;
/**
* Interface for the ex-/import routine. With this interface any object class
* can declare itself ex- or im{@code portable}.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 11/3/16
*/
public interface Portable {}

View File

@ -91,6 +91,7 @@ public class ExportCliTool extends Program {
break;
case "export":
convert();
export(args);
break;
@ -103,19 +104,23 @@ 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 " +
"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 method = cls.getMethod("startConversionToNg");
method.invoke(cls.newInstance());
Method startConversionToNg = cls
.getDeclaredMethod("startConversionToNg");
startConversionToNg.invoke(cls.newInstance());
}
System.err.println("Finished conversions.");
@ -133,109 +138,44 @@ public class ExportCliTool extends Program {
*
* @param args The secondary command line arguments
*/
@SuppressWarnings("unchecked")
private void export(String[] args) {
if (args.length != 3) {
if (args.length != 2) {
printUsage();
System.exit(-1);
}
final String moduleClass = args[1];
System.err.printf("module-class: %s\n", moduleClass);
final String pathName = args[2];
//final String moduleClass = args[1];
//System.err.printf("module-class: %s\n", moduleClass);
final String pathName = args[1];
System.err.printf("path: %s\n", pathName);
CoreExporter.setPath(pathName);
System.err.printf("\n");
try {
switch (moduleClass) {
case "users":
convert();
CoreExporter.exportUsers();
break;
System.out.println("Started exporting all ng-objects...");
case "groups":
convert();
CoreExporter.exportGroups();
break;
case "groupMemberships":
convert();
CoreExporter.exportGroupMemberships();
break;
case "roles":
convert();
CoreExporter.exportRoles();
break;
case "roleMemberships":
convert();
CoreExporter.exportRoleMemberships();
break;
case "categories":
convert();
CoreExporter.exportCategories();
break;
case "categorizations":
convert();
CoreExporter.exportCategorizations();
break;
case "workflowTemplates":
convert();
CoreExporter.exportWorkflowTemplates();
break;
case "workflows":
convert();
CoreExporter.exportWorkflows();
break;
case "assignableTasks":
convert();
CoreExporter.exportAssignableTasks();
break;
case "taskAssignments":
convert();
CoreExporter.exportTaskAssignments();
break;
case "permissions":
convert();
CoreExporter.exportPermissions();
break;
default:
convert();
System.out.println("Started exporting all ng-objects...");
CoreExporter.exportUsers();
CoreExporter.exportGroups();
CoreExporter.exportGroupMemberships();
CoreExporter.exportRoles();
CoreExporter.exportRoleMemberships();
CoreExporter.exportCategories();
CoreExporter.exportCategorizations();
CoreExporter.exportWorkflows();
CoreExporter.exportWorkflowTemplates();
CoreExporter.exportAssignableTasks();
CoreExporter.exportTaskAssignments();
CoreExporter.exportPermissions();
System.out.println("Finished exports.");
System.out.printf("\n");
break;
// 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());
}
System.out.println("Finished exports.");
System.out.printf("\n");
} catch (Exception ex) {
logger.error("ERROR while exporting", ex);
}
}
/**
* Prints the usage of this command line tool.
*/

View File

@ -24,7 +24,6 @@ import com.arsdigita.portation.modules.core.security.Group;
import com.arsdigita.portation.modules.core.security.GroupMembership;
import com.arsdigita.portation.modules.core.security.User;
import java.util.ArrayList;
import java.util.List;
/**
@ -46,9 +45,8 @@ public class GroupConversion {
*/
public static void convertAll() {
System.err.printf("\tFetching groups from database...");
List<com.arsdigita.kernel.Group> trunkGroups,
roleGroups = new ArrayList<>();
trunkGroups = com.arsdigita.kernel.Group.getAllObjectGroups();
List<com.arsdigita.kernel.Group> trunkGroups = com.arsdigita.kernel
.Group.getAllObjectGroups();
System.err.println("done.");
System.err.printf("\tConverting groups and group memberships...\n");

View File

@ -125,7 +125,6 @@ public class PermissionConversion {
processed++;
}
System.err.printf("\t\tCreated %d permissions and skipped: %d.\n",
processed, skipped);
}

View File

@ -67,16 +67,17 @@ public class WorkflowConversion {
trunkWorkflowTemplate = trunkWorkflow.getWorkflowTemplate();
if (trunkWorkflowTemplate != null) {
WorkflowTemplate workflowTemplate = NgCoreCollection
.workflowTemplates.get(trunkWorkflowTemplate.getID()
.longValue());
.workflowTemplates
.get(trunkWorkflowTemplate.getID().longValue());
workflow.setTemplate(workflowTemplate);
}
// set object association
ACSObject trunkObject = trunkWorkflow.getObject();
if (trunkObject != null) {
CcmObject object = NgCoreCollection.ccmObjects.get(trunkObject
.getID().longValue());
CcmObject object = NgCoreCollection
.ccmObjects
.get(trunkObject.getID().longValue());
workflow.setObject(object);
}

View File

@ -39,138 +39,148 @@ import java.util.ArrayList;
* @version created on 25.07.2016
*/
public class CoreExporter extends AbstractExporter {
public static void startExport() {
exportUsers();
exportGroups();
exportGroupMemberships();
exportRoles();
exportRoleMemberships();
public static void exportUsers() {
exportCategories();
exportCategorizations();
exportWorkflows();
exportWorkflowTemplates();
exportAssignableTasks();
exportTaskAssignments();
exportPermissions();
}
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()));
userMarshaller.prepare(
Format.XML, pathName, "users", indentation);
userMarshaller.exportList(
new ArrayList<>(NgCoreCollection.users.values()));
System.out.printf("\t\tdone.\n");
}
public static void exportGroups() {
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()));
groupMarshaller.prepare(
Format.XML, pathName, "groups", indentation);
groupMarshaller.exportList(
new ArrayList<>(NgCoreCollection.groups.values()));
System.out.printf("\t\tdone.\n");
}
public static void exportGroupMemberships() {
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()));
groupMembershipMarshaller.prepare(
Format.XML, pathName, "groupMemberships", indentation);
groupMembershipMarshaller.exportList(
new ArrayList<>(NgCoreCollection.groupMemberships.values()));
System.out.printf("\tdone.\n");
}
public static void exportRoles() {
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()));
roleMarshaller.prepare(
Format.XML, pathName, "roles", indentation);
roleMarshaller.exportList(
new ArrayList<>(NgCoreCollection.roles.values()));
System.out.printf("\t\tdone.\n");
}
public static void exportRoleMemberships() {
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()));
roleMembershipMarshaller.prepare(
Format.XML, pathName, "roleMemberships", indentation);
roleMembershipMarshaller.exportList(
new ArrayList<>(NgCoreCollection.roleMemberships.values()));
System.out.printf("\tdone.\n");
}
public static void exportCategories() {
private static void exportCategories() {
System.out.printf("\tExporting categories...");
CategoryMarshaller categoryMarshaller = new CategoryMarshaller();
categoryMarshaller
.prepare(Format.XML, pathName, "categories", indentation);
categoryMarshaller
.exportList(NgCoreCollection.sortedCategories);
categoryMarshaller.prepare(
Format.XML, pathName, "categories", indentation);
categoryMarshaller.exportList(NgCoreCollection.sortedCategories);
System.out.printf("\t\tdone.\n");
}
public static void exportCategorizations() {
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()));
categorizationMarshaller.prepare(
Format.XML, pathName, "categorizations", indentation);
categorizationMarshaller.exportList(
new ArrayList<>(NgCoreCollection.categorizations.values()));
System.out.printf("\tdone.\n");
}
public static void exportWorkflowTemplates() {
private 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()));
workflowTemplateMarshaller.prepare(
Format.XML, pathName, "workflowTemplates", indentation);
workflowTemplateMarshaller.exportList(
new ArrayList<>(NgCoreCollection.workflowTemplates.values()));
System.out.printf("\tdone.\n");
}
public static void exportWorkflows() {
private 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()));
workflowMarshaller.prepare(
Format.XML, pathName, "workflows", indentation);
workflowMarshaller.exportList(
new ArrayList<>(NgCoreCollection.workflows.values()));
System.out.printf("\t\tdone.\n");
}
public static void exportAssignableTasks() {
private 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()));
assignableTaskMarshaller.prepare(
Format.XML, pathName, "assignableTasks", indentation);
assignableTaskMarshaller.exportList(
new ArrayList<>(NgCoreCollection.assignableTasks.values()));
System.out.printf("\tdone.\n");
}
public static void exportTaskAssignments() {
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()));
taskAssignmentMarshaller.prepare(
Format.XML, pathName, "taskAssignments", indentation);
taskAssignmentMarshaller.exportList(
new ArrayList<>(NgCoreCollection.taskAssignments.values()));
System.out.printf("\tdone.\n");
}
public static void exportPermissions() {
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()));
permissionMarshaller.prepare(
Format.XML, pathName, "permissions", indentation);
permissionMarshaller.exportList(
new ArrayList<>(NgCoreCollection.permissions.values()));
System.out.printf("\tdone.\n");
}
}

View File

@ -74,18 +74,18 @@ public class CcmObject {
NgCoreCollection.ccmObjects.put(this.objectId, this);
}
public CcmObject() {}
/*public CcmObject(final Domain trunkDomain) {
// specific constructor for ldn-terms' domain
public CcmObject(String domainKey) {
this.objectId = ACSObject.generateID().longValue();
this.uuid = UUID.randomUUID().toString();
this.displayName = trunkDomain.getKey() + "_DName";
this.displayName = domainKey + "_DName";
this.permissions = new ArrayList<>();
this.categories = new ArrayList<>();
NgCoreCollection.ccmObjects.put(this.objectId, this);
}*/
}
public long getObjectId() {
return objectId;

View File

@ -24,10 +24,7 @@ import com.arsdigita.kernel.ACSObject;
import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.Resource;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.*;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
@ -784,4 +781,26 @@ public class Application extends Resource {
(DataObject) get("containerGroup"));
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all applications
*/
public static List<Application> getAllApplicationObjects() {
List<Application> applicationList = new ArrayList<>();
ApplicationCollection collection = Application
.retrieveAllApplications();
while (collection.next()) {
Application application = (Application) collection.getDomainObject();
if (application != null) {
applicationList.add(application);
}
}
collection.close();
return applicationList;
}
}

View File

@ -19,6 +19,8 @@
package com.arsdigita.london.terms.portation.conversion;
import com.arsdigita.london.terms.portation.conversion.core.categorization.DomainConversion;
import com.arsdigita.london.terms.portation.conversion.core.core.ResourceTypeConversion;
import com.arsdigita.london.terms.portation.conversion.core.web.CcmApplicationConversion;
import com.arsdigita.portation.AbstractConverter;
/**
@ -46,6 +48,8 @@ public class LdnTermsConverter extends AbstractConverter {
@Override
public void startConversionToNg() {
DomainConversion.convertAll();
ResourceTypeConversion.convertAll();
CcmApplicationConversion.convertAll();
}
/**

View File

@ -19,6 +19,9 @@
package com.arsdigita.london.terms.portation.conversion;
import com.arsdigita.london.terms.portation.modules.core.categorization.Domain;
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 java.util.HashMap;
import java.util.Map;
@ -30,6 +33,10 @@ import java.util.Map;
public class NgCoreCollection {
public static Map<Long, Domain> domains = new HashMap<>();
public static Map<Long, ResourceType> resourceTypes = new HashMap<>();
public static Map<Long, Resource> resources = new HashMap<>();
public static Map<Long, CcmApplication> ccmApplications = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/

View File

@ -51,6 +51,13 @@ public class DomainConversion {
System.err.printf("\tdone.\n");
}
/**
* Creates the equivalent ng-class of the {@code Domain} and restores
* the associations to other classes.
*
* @param trunkDomains List of all {@link com.arsdigita.london.terms.Domain}s
* from this old trunk-system.
*/
private static void createDomainsAndSetAssociations(
List<com.arsdigita.london.terms.Domain> trunkDomains) {
long processed = 0;

View File

@ -0,0 +1,53 @@
/*
* 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.core;
import com.arsdigita.london.terms.portation.modules.core.core.ResourceType;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class 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...");
List<com.arsdigita.kernel.ResourceType> trunkResourceTypes = com
.arsdigita.kernel.ResourceType.getAllObjectResourceTypes();
System.err.println("done.");
System.err.printf("\tConverting domains...\n");
// create resource types
long processed = 0;
for (com.arsdigita.kernel.ResourceType trunkResourceType :
trunkResourceTypes) {
new ResourceType(trunkResourceType);
processed++;
}
System.out.printf("\t\tCreated %d resource types.\n", processed);
System.err.printf("\tdone.\n");
}
}

View File

@ -0,0 +1,116 @@
/*
* 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.web;
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.web.Application;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class 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...");
List<Application> trunkApplications = Application
.getAllApplicationObjects();
System.err.println("done.");
System.err.printf("\tConverting ccm applications...\n");
// create ccm applications
createCcmApplicationsAndSetAssociations(trunkApplications);
setRingAssociations(trunkApplications);
System.err.printf("\tdone.\n");
}
/**
* Creates the equivalent ng-class of the {@code Application} and restores
* the associations to other classes.
*
* @param trunkApplications List of all {@link Application}s
* from this old trunk-system.
*/
private static void createCcmApplicationsAndSetAssociations(
List<Application> trunkApplications) {
long processed = 0;
for (Application trunkApplication : trunkApplications) {
// create applications
CcmApplication ccmApplication = new CcmApplication
(trunkApplication);
// set resource type
com.arsdigita.kernel.ResourceType trunkResourceType = trunkApplication
.getResourceType();
if (trunkResourceType != null) {
ResourceType resourceType = NgCoreCollection
.resourceTypes
.get(trunkResourceType.getID().longValue());
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);
}
/**
* Method for setting the parent {@link Resource} on the one side and the
* sub-{@link Resource}s on the other side. Attribute of class
* {@link Resource}.
*
* @param trunkApplications List of all {@link Application} from the old
* trunk-system.
*/
private static 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;
Application trunkParent = trunkApplication
.getParentApplication();
if (trunkParent != null) {
parentResource = NgCoreCollection
.ccmApplications
.get(trunkParent.getID().longValue());
ccmApplication.setParent(parentResource);
parentResource.addChild(ccmApplication);
}
}
}
}

View File

@ -19,7 +19,9 @@
package com.arsdigita.london.terms.portation.modules;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.london.terms.portation.modules.core.core.ResourceTypeMarshaller;
import com.arsdigita.london.terms.portation.modules.core.categorization.DomainMarshaller;
import com.arsdigita.london.terms.portation.modules.core.web.CcmApplicationMarshaller;
import com.arsdigita.portation.AbstractExporter;
import com.arsdigita.portation.Format;
@ -29,19 +31,49 @@ import java.util.ArrayList;
* Helper to implement the specifics for the exportation. Makes source code
* in the cli-tool shorter and more readable.
*
* Their exists no direct usage of this class. It is used via reflections in
* the ccm-core package to start export of these classes.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/28/17
*/
public class LdnTermsExporter extends AbstractExporter {
public static void exportUsers() {
public static void startExport() {
exportDomains();
exportResourceTypes();
exportCcmApplications();
}
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()));
domainMarshaller.prepare(
Format.XML, pathName, "domains", indentation);
domainMarshaller.exportList(
new ArrayList<>(NgCoreCollection.domains.values()));
System.out.printf("\t\tdone.\n");
}
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");
}
private static void exportCcmApplications() {
System.out.printf("\tExporting ccm applications...");
CcmApplicationMarshaller ccmApplicationMarshaller = new
CcmApplicationMarshaller();
ccmApplicationMarshaller.prepare(
Format.XML, pathName, "ccmApplications", indentation);
ccmApplicationMarshaller.exportList(
new ArrayList<>(NgCoreCollection.ccmApplications.values()));
System.out.printf("\tdone.\n");
}
}

View File

@ -18,12 +18,14 @@
*/
package com.arsdigita.london.terms.portation.modules.core.categorization;
import com.arsdigita.kernel.ACSObject;
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 com.fasterxml.jackson.annotation.*;
import java.util.ArrayList;
import java.util.Date;
@ -44,6 +46,9 @@ import java.util.Locale;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/27/17
*/
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = DomainIdResolver.class,
property = "uuid")
public class Domain extends CcmObject implements Portable {
private String domainKey;
@ -52,12 +57,15 @@ public class Domain extends CcmObject implements Portable {
private LocalizedString description;
private String version;
private Date released;
@JsonIdentityReference(alwaysAsId = true)
private Category root;
@JsonIgnore
private List<DomainOwnership> owners;
public Domain(com.arsdigita.london.terms.Domain trunkDomain) {
super();
super(trunkDomain.getKey());
this.domainKey = trunkDomain.getKey();
this.uri = trunkDomain.getURL().toString();
@ -65,8 +73,8 @@ public class Domain extends CcmObject implements Portable {
this.title = new LocalizedString();
this.title.addValue(Locale.getDefault(), trunkDomain.getTitle());
this.description = new LocalizedString();
this.description.addValue(Locale.getDefault(), trunkDomain
.getDescription());
this.description
.addValue(Locale.getDefault(), trunkDomain.getDescription());
this.version = trunkDomain.getVersion();
this.released = trunkDomain.getReleased();

View File

@ -0,0 +1,50 @@
/*
* 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.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class DomainIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey idKey) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new DomainIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof DomainIdResolver;
}
}

View File

@ -20,6 +20,7 @@ package com.arsdigita.london.terms.portation.modules.core.categorization;
import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.web.Application;
/**
* Association class for the association between a {@link Domain} and a
@ -39,6 +40,12 @@ public class DomainOwnership {
private long ownerOrder;
private long domainOrder;
public DomainOwnership() {
}
public long getOwnershipId() {
return ownershipId;

View File

@ -18,13 +18,19 @@
*/
package com.arsdigita.london.terms.portation.modules.core.core;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
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 com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* The {@code Resource} class is a base class for several other classes, for
@ -40,18 +46,37 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/27/17
*/
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = ResourceIdResolver.class,
property = "uuid")
public class Resource extends CcmObject {
private LocalizedString title;
private LocalizedString description;
@JsonIdentityReference(alwaysAsId = true)
private ResourceType resourceType;
private Date created;
@JsonIgnore
private List<Resource> childs;
@JsonIdentityReference(alwaysAsId = true)
private Resource parent;
public Resource(ACSObject trunkObject) {
public Resource(com.arsdigita.kernel.Resource trunkObject) {
super(trunkObject);
this.title = new LocalizedString();
this.title.addValue(Locale.getDefault(), trunkObject.getTitle());
this.description = new LocalizedString();
this.description
.addValue(Locale.getDefault(), trunkObject.getDescription());
//this.resourceType;
this.created = trunkObject.getTimestamp();
this.childs = new ArrayList<>();
//this.parent
NgCoreCollection.resources.put(this.getObjectId(), this);
}
@ -95,6 +120,14 @@ public class Resource extends CcmObject {
this.childs = childs;
}
public void addChild(final Resource child) {
this.childs.add(child);
}
public void removeChild(final Resource child) {
this.childs.remove(child);
}
public Resource getParent() {
return parent;
}

View File

@ -0,0 +1,50 @@
/*
* 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.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class ResourceIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey idKey) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new ResourceIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof ResourceIdResolver;
}
}

View File

@ -18,7 +18,13 @@
*/
package com.arsdigita.london.terms.portation.modules.core.core;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import java.util.Locale;
/**
* This class is a port of the old {@code ResourceType} entity.
@ -33,7 +39,10 @@ import com.arsdigita.portation.modules.core.l10n.LocalizedString;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/27/17
*/
public class ResourceType {
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = ResourceTypeIdResolver.class,
property = "title")
public class ResourceType implements Portable {
private long resourceTypeId;
private String title;
@ -43,6 +52,21 @@ public class ResourceType {
private boolean viewableAsEmbedded;
private boolean singleton;
public ResourceType(com.arsdigita.kernel.ResourceType trunkObject) {
this.resourceTypeId = trunkObject.getID().longValue();
this.title = trunkObject.getTitle();
this.description = new LocalizedString();
this.description
.addValue(Locale.getDefault(), trunkObject.getDescription());
this.workspaceApplication = false;
this.viewableAsFullPage = false;
this.viewableAsEmbedded = false;
this.singleton = false;
NgCoreCollection.resourceTypes.put(this.resourceTypeId, this);
}
public long getResourceTypeId() {
return resourceTypeId;

View File

@ -0,0 +1,50 @@
/*
* 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.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class ResourceTypeIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey idKey) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new ResourceTypeIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resovlerType) {
return resovlerType instanceof ResourceTypeIdResolver;
}
}

View File

@ -0,0 +1,29 @@
/*
* 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.london.terms.portation.modules.core.core.ResourceType;
import com.arsdigita.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/3/17
*/
public class ResourceTypeMarshaller extends AbstractMarshaller<ResourceType> {
}

View File

@ -18,25 +18,42 @@
*/
package com.arsdigita.london.terms.portation.modules.core.web;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
import com.arsdigita.london.terms.portation.modules.core.categorization.DomainOwnership;
import com.arsdigita.london.terms.portation.modules.core.core.Resource;
import com.arsdigita.portation.Portable;
import com.arsdigita.web.Application;
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.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/27/17
*/
public class CcmApplication extends Resource {
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = CcmApplicationIdResolver.class,
property = "uuid")
public class CcmApplication extends Resource implements Portable {
private String applicationType;
private String primaryUrl;
@JsonIgnore
private List<DomainOwnership> domains;
public CcmApplication(ACSObject trunkObject) {
public CcmApplication(Application trunkObject) {
super(trunkObject);
this.applicationType = trunkObject.getApplicationType().toString();
this.primaryUrl = trunkObject.getPrimaryURL();
this.domains = new ArrayList<>();
NgCoreCollection.ccmApplications.put(getObjectId(), this);
}

View File

@ -0,0 +1,50 @@
/*
* 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.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class CcmApplicationIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey idKey) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new CcmApplicationIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof CcmApplicationIdResolver;
}
}

View File

@ -0,0 +1,28 @@
/*
* 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.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/3/17
*/
public class CcmApplicationMarshaller extends AbstractMarshaller<CcmApplication> {
}