[TRUNK][FEATURE]
- adds working export of ldn-terms' ResourceType, CcmApplication, Domain and DomainOwnership - optimizes imports of some core packages git-svn-id: https://svn.libreccm.org/ccm/trunk@4986 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9cdab4335c
commit
06487845bb
|
|
@ -108,7 +108,7 @@ public class ExportCliTool extends Program {
|
|||
private void convert() {
|
||||
try {
|
||||
System.err.println("Started conversions of systems objects to " +
|
||||
"ng-objects...");
|
||||
"ng-objects:");
|
||||
|
||||
// Core conversions
|
||||
CoreConverter.getInstance().startConversionToNg();
|
||||
|
|
@ -148,13 +148,13 @@ public class ExportCliTool extends Program {
|
|||
//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);
|
||||
System.err.printf("path for export: %s\n", pathName);
|
||||
CoreExporter.setPath(pathName);
|
||||
System.err.printf("\n");
|
||||
|
||||
|
||||
try {
|
||||
System.out.println("Started exporting all ng-objects...");
|
||||
System.out.println("Started exporting all ng-objects:");
|
||||
|
||||
// Core
|
||||
CoreExporter.startExport();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ 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.conversion.core.workflow.WorkflowTemplateConversion;
|
||||
import com.arsdigita.portation.modules.core.security.Permission;
|
||||
|
||||
|
||||
|
|
@ -55,23 +56,11 @@ public class CoreConverter extends AbstractConverter {
|
|||
public void startConversionToNg() {
|
||||
UserConversion.convertAll();
|
||||
GroupConversion.convertAll();
|
||||
|
||||
RoleConversion.convertAll();
|
||||
|
||||
CategoryConversion.convertAll();
|
||||
NgCoreCollection.sortCategories();
|
||||
// Verify categories
|
||||
/*for (Category category : NgCoreCollection.sortedCategories) {
|
||||
System.err.printf("\t\t\tCategory %s with parent category %s\n",
|
||||
category.getName(), category.getParentCategory().getName()
|
||||
);
|
||||
}*/
|
||||
|
||||
WorkflowConversion.convertAll();
|
||||
AssignableTaskConversion.convertAll();
|
||||
|
||||
PermissionConversion.convertAll();
|
||||
|
||||
// Verify permissions
|
||||
for (Permission permission : NgCoreCollection.permissions.values()) {
|
||||
if (permission.getGrantee() == null) {
|
||||
|
|
@ -80,6 +69,10 @@ public class CoreConverter extends AbstractConverter {
|
|||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
WorkflowConversion.convertAll();
|
||||
WorkflowTemplateConversion.convertAll();
|
||||
AssignableTaskConversion.convertAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class NgCoreCollection {
|
|||
// if lists need to be sorted in specific way to work with import
|
||||
public static ArrayList<Category> sortedCategories;
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor to prevent the instantiation of this class.
|
||||
*/
|
||||
|
|
@ -68,26 +69,24 @@ public class NgCoreCollection {
|
|||
|
||||
/**
|
||||
* Sorts values of category-map to ensure that the parent-categories will
|
||||
* be listed befor their childs in the export file.
|
||||
* be listed before their childs in the export file.
|
||||
*
|
||||
* Runs once over the unsorted list and iterates over each their parents
|
||||
* to add them to the sorted list. After being added to sorted the
|
||||
* to add them to the sorted list. After being added to the sorted list the
|
||||
* category will be removed from the unsorted list and therefore ignored
|
||||
* in this foreach run.
|
||||
*/
|
||||
static void sortCategories() {
|
||||
ArrayList<Category> unsortedCategories = new ArrayList<>(categories.values());
|
||||
public static void sortCategories() {
|
||||
ArrayList<Category> unsortedCategories =
|
||||
new ArrayList<>(categories.values());
|
||||
sortedCategories = new ArrayList<>(unsortedCategories.size());
|
||||
|
||||
System.err.printf("\tSorting categorizes...\n");
|
||||
int count = 1;
|
||||
int runs = 0;
|
||||
for (Category anUnsorted : unsortedCategories) {
|
||||
//System.err.printf("\t\tNumber: %d\n", count++);
|
||||
//System.err.printf("\t\tCategory: %s\n", anUnsorted.getName());
|
||||
add(anUnsorted, "\t\t");
|
||||
//System.err.println("");
|
||||
add(anUnsorted);
|
||||
runs++;
|
||||
}
|
||||
System.err.printf("\tdone. Count: %d\n", sortedCategories.size());
|
||||
System.err.printf("\t\tSorted categories in %d runs.\n", runs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,25 +95,15 @@ public class NgCoreCollection {
|
|||
*
|
||||
* @param category the current category in the unsorted list
|
||||
*/
|
||||
private static void add(Category category, String indent) {
|
||||
private static void add(Category category) {
|
||||
Category parent = category.getParentCategory();
|
||||
|
||||
//System.err.printf("%s\tHas missing parent?...", indent);
|
||||
if (parent != null && !sortedCategories.contains(parent)) {
|
||||
//System.err.println("YES.");
|
||||
//System.err.printf("%s\tParent: %s\n", indent, parent.getName());
|
||||
|
||||
add(parent, String.format("%s\t", indent));
|
||||
} else {
|
||||
//System.err.println("NO.");
|
||||
add(parent);
|
||||
}
|
||||
|
||||
//System.err.printf("%sAdded to sorted list?...", indent);
|
||||
if (!sortedCategories.contains(category)) {
|
||||
sortedCategories.add(category);
|
||||
//System.err.println("YES.");
|
||||
} else {
|
||||
//System.err.println("NO.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ public class CategoryConversion {
|
|||
System.err.printf("\tConverting categories and categorizations...\n");
|
||||
createCategoryAndCategorizations(trunkCategories);
|
||||
setRingAssociations(trunkCategories);
|
||||
System.err.printf("\tdone.\n");
|
||||
|
||||
System.err.printf("\tSorting categories...\n");
|
||||
NgCoreCollection.sortCategories();
|
||||
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class GroupConversion {
|
|||
|
||||
System.err.printf("\tConverting groups and group memberships...\n");
|
||||
createGroupsAndSetAssociations(trunkGroups);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class PermissionConversion {
|
|||
System.exit(-1);
|
||||
}
|
||||
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -254,9 +254,9 @@ public class PermissionConversion {
|
|||
permission.getPermissionId());*/
|
||||
}
|
||||
}
|
||||
System.err.printf("\t\tCreated %d duplicate permissions.\n",
|
||||
System.err.printf("\t\t(Created %d duplicates.)\n",
|
||||
duplicates);
|
||||
System.err.printf("\t\tCreated %d new roles.\n",
|
||||
System.err.printf("\t\t(Created %d new roles.)\n",
|
||||
rolesCreated);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class RoleConversion {
|
|||
|
||||
System.err.printf("\tCreating roles and role memberships...\n");
|
||||
createRolesAndSetAssociations(trunkRoles);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,6 +51,6 @@ public class UserConversion {
|
|||
processed++;
|
||||
}
|
||||
System.out.printf("\t\tCreated %d users.\n", processed);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class AssignableTaskConversion {
|
|||
"assignments...\n");
|
||||
createAssignableTasksAndSetAssociations(trunkUserTasks);
|
||||
setTaskRingDependencies(trunkUserTasks);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class WorkflowConversion {
|
|||
|
||||
System.err.printf("\tConverting workflows...\n");
|
||||
createWorkflowAndSetAssociations(trunkWorkflows);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
private static void createWorkflowAndSetAssociations(
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class WorkflowTemplateConversion {
|
|||
new WorkflowTemplate(trunkWorkflowTemplate);
|
||||
processed++;
|
||||
}
|
||||
System.out.printf("\t\t Created %d workflow templates.", processed);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.out.printf("\t\t Created %d workflow templates.\n", processed);
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,9 +72,10 @@ public class Category extends CcmObject implements Portable {
|
|||
this.uniqueId = trunkCategory.getID().toString();
|
||||
this.name = trunkCategory.getName();
|
||||
|
||||
this.title = new LocalizedString();
|
||||
this.description = new LocalizedString();
|
||||
CategoryLocalizationCollection categoryLocalizationCollection =
|
||||
trunkCategory.getCategoryLocalizationCollection();
|
||||
|
||||
if (categoryLocalizationCollection != null &&
|
||||
categoryLocalizationCollection.next()) {
|
||||
|
||||
|
|
@ -82,9 +83,7 @@ public class Category extends CcmObject implements Portable {
|
|||
categoryLocalizationCollection.getCategoryLocalization();
|
||||
if (categoryLocalization != null) {
|
||||
Locale locale = new Locale(categoryLocalization.getLocale());
|
||||
this.title = new LocalizedString();
|
||||
this.title.addValue(locale, categoryLocalization.getName());
|
||||
this.description = new LocalizedString();
|
||||
this.description.addValue(locale, categoryLocalization.getDescription());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ 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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -39,8 +40,53 @@ public class NgCoreCollection {
|
|||
public static Map<Long, Domain> domains = new HashMap<>();
|
||||
public static Map<Long, DomainOwnership> domainOwnerships = new HashMap<>();
|
||||
|
||||
|
||||
// if lists need to be sorted in specific way to work with import
|
||||
public static ArrayList<CcmApplication> sortedCcmApplications;
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor to prevent the instantiation of this class.
|
||||
*/
|
||||
private NgCoreCollection() {}
|
||||
|
||||
/**
|
||||
* Sorts values of resource-map to ensure that the parent-resources will
|
||||
* be listed before their childs in the export file.
|
||||
*
|
||||
* Runs once over the unsorted list and iterates over each their parents
|
||||
* to add them to the sorted list. After being added to the sorted list the
|
||||
* resource will be removed from the unsorted list and therefore ignored
|
||||
* in this foreach run.
|
||||
*/
|
||||
public static void sortCcmApplications() {
|
||||
ArrayList<CcmApplication> unsortedCcmApplications =
|
||||
new ArrayList<>(ccmApplications.values());
|
||||
sortedCcmApplications = new ArrayList<>(unsortedCcmApplications.size());
|
||||
|
||||
int runs = 0;
|
||||
for (CcmApplication anUnsorted : unsortedCcmApplications) {
|
||||
add(anUnsorted);
|
||||
runs++;
|
||||
}
|
||||
System.err.printf("\t\tSorted ccm applications in %d runs.\n", runs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to recursively add all parent resources before their
|
||||
* childs.
|
||||
*
|
||||
* @param ccmApplication the current resource in the unsorted list
|
||||
*/
|
||||
private static void add(CcmApplication ccmApplication) {
|
||||
CcmApplication parent = (CcmApplication) ccmApplication.getParent();
|
||||
|
||||
if (parent != null && !sortedCcmApplications.contains(parent)) {
|
||||
add(parent);
|
||||
}
|
||||
|
||||
if (!sortedCcmApplications.contains(ccmApplication)) {
|
||||
sortedCcmApplications.add(ccmApplication);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class DomainConversion {
|
|||
|
||||
System.err.printf("\tConverting domains and domain ownerships...\n");
|
||||
createDomainsAndSetAssociations(trunkDomains);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -52,6 +52,6 @@ public class ResourceTypeConversion {
|
|||
processed++;
|
||||
}
|
||||
System.out.printf("\t\tCreated %d resource types.\n", processed);
|
||||
System.err.printf("\tdone.\n");
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,11 @@ public class CcmApplicationConversion {
|
|||
// create ccm applications
|
||||
createCcmApplicationsAndSetAssociations(trunkApplications);
|
||||
setRingAssociations(trunkApplications);
|
||||
System.err.printf("\tdone.\n");
|
||||
|
||||
System.err.printf("\tSorting ccm applications...\n");
|
||||
NgCoreCollection.sortCcmApplications();
|
||||
|
||||
System.err.println("\tdone.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,22 +41,12 @@ import java.util.ArrayList;
|
|||
public class LdnTermsExporter extends AbstractExporter {
|
||||
|
||||
public static void startExport() {
|
||||
exportDomains();
|
||||
exportResourceTypes();
|
||||
exportCcmApplications();
|
||||
exportDomains();
|
||||
exportDomainOwnerships();
|
||||
}
|
||||
|
||||
private static void exportDomains() {
|
||||
System.out.printf("\tExporting domains...");
|
||||
DomainMarshaller domainMarshaller = new DomainMarshaller();
|
||||
domainMarshaller.prepare(
|
||||
Format.XML, pathName, "domains", indentation);
|
||||
domainMarshaller.exportList(
|
||||
new ArrayList<>(NgCoreCollection.domains.values()));
|
||||
System.out.printf("\t\tdone.\n");
|
||||
}
|
||||
|
||||
private static void exportResourceTypes() {
|
||||
System.out.printf("\tExporting resource types...");
|
||||
ResourceTypeMarshaller resourceTypeMarshaller = new
|
||||
|
|
@ -79,6 +69,16 @@ public class LdnTermsExporter extends AbstractExporter {
|
|||
System.out.printf("\tdone.\n");
|
||||
}
|
||||
|
||||
private static void exportDomains() {
|
||||
System.out.printf("\tExporting domains...");
|
||||
DomainMarshaller domainMarshaller = new DomainMarshaller();
|
||||
domainMarshaller.prepare(
|
||||
Format.XML, pathName, "domains", indentation);
|
||||
domainMarshaller.exportList(
|
||||
new ArrayList<>(NgCoreCollection.domains.values()));
|
||||
System.out.printf("\t\tdone.\n");
|
||||
}
|
||||
|
||||
private static void exportDomainOwnerships() {
|
||||
System.out.printf("\tExporting domain ownerships...");
|
||||
DomainOwnershipMarshaller domainOwnershipMarshaller = new
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ public class DomainOwnershipIdGenerator extends ObjectIdGenerator<String> {
|
|||
|
||||
@Override
|
||||
public boolean canUseFor(ObjectIdGenerator gen) {
|
||||
return gen instanceof DomainOwnershipIdGenerator;
|
||||
if (gen instanceof DomainOwnershipIdGenerator) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue