[TRUNK][FEATURE]
- adds conversion and export of domain ownerships for import in ng - modifies some minor code styles git-svn-id: https://svn.libreccm.org/ccm/trunk@4904 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4ae670f033
commit
2f3a00d3d0
|
|
@ -438,7 +438,7 @@ public abstract class DomainObject {
|
|||
*
|
||||
* @see com.arsdigita.persistence.DataObject#get(String)
|
||||
**/
|
||||
protected Object get(String attr) {
|
||||
public Object get(String attr) {
|
||||
return m_dataObject.get(attr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class CategoryConversion {
|
|||
*/
|
||||
private static void createCategoryAndCategorizations(
|
||||
List<com.arsdigita.categorization.Category> trunkCategories) {
|
||||
long pCategories = 0, pCategorizations = 0;
|
||||
long processedCategories = 0, processedCategorizations = 0;
|
||||
|
||||
|
||||
for (com.arsdigita.categorization.Category
|
||||
|
|
@ -75,17 +75,17 @@ public class CategoryConversion {
|
|||
// create categories
|
||||
Category category = new Category(trunkCategory);
|
||||
|
||||
// categorizations only for category typed objects
|
||||
// create categorizations only for category typed objects
|
||||
CategorizedCollection categorizedCollection = trunkCategory
|
||||
.getObjects(com.arsdigita.categorization.Category
|
||||
.BASE_DATA_OBJECT_TYPE);
|
||||
pCategorizations += createCategorizations(category,
|
||||
.getObjects(com.arsdigita.categorization
|
||||
.Category.BASE_DATA_OBJECT_TYPE);
|
||||
processedCategorizations += createCategorizations(category,
|
||||
categorizedCollection);
|
||||
|
||||
pCategories++;
|
||||
processedCategories++;
|
||||
}
|
||||
System.err.printf("\t\tCreated %d categories and %d categorizations." +
|
||||
"\n", pCategories, pCategorizations);
|
||||
"\n", processedCategories, processedCategorizations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,6 +96,8 @@ public class CategoryConversion {
|
|||
* @param category The {@link Category}
|
||||
* @param categorizedObjects A collection of the {@code Categorization}s
|
||||
* as they are represented in this trunk-system
|
||||
*
|
||||
* @return Number of how many {@link Categorization}s have been processed.
|
||||
*/
|
||||
private static long createCategorizations(Category category,
|
||||
CategorizedCollection
|
||||
|
|
@ -103,8 +105,12 @@ public class CategoryConversion {
|
|||
long processed = 0;
|
||||
|
||||
while (categorizedObjects.next()) {
|
||||
CcmObject categorizedObject = NgCoreCollection.ccmObjects.get(((ACSObject)
|
||||
categorizedObjects.getDomainObject()).getID().longValue());
|
||||
CcmObject categorizedObject = NgCoreCollection
|
||||
.ccmObjects
|
||||
.get(((ACSObject) categorizedObjects
|
||||
.getDomainObject())
|
||||
.getID()
|
||||
.longValue());
|
||||
|
||||
if (category != null && categorizedObject != null) {
|
||||
// create categorizations
|
||||
|
|
@ -114,11 +120,10 @@ public class CategoryConversion {
|
|||
// set opposed associations
|
||||
category.addObject(categorization);
|
||||
categorizedObject.addCategory(categorization);
|
||||
}
|
||||
|
||||
processed++;
|
||||
}
|
||||
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,11 +104,12 @@ public class GroupConversion {
|
|||
// set opposed associations
|
||||
group.addMembership(groupMembership);
|
||||
member.addGroupMembership(groupMembership);
|
||||
}
|
||||
|
||||
processed++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@ public class RoleConversion {
|
|||
// set opposed associations
|
||||
role.addMembership(roleMembership);
|
||||
member.addRoleMembership(roleMembership);
|
||||
}
|
||||
|
||||
processed++;
|
||||
}
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,10 +170,11 @@ public class AssignableTaskConversion {
|
|||
// set opposed associations
|
||||
assignableTask.addAssignment(taskAssignment);
|
||||
role.addAssignedTask(taskAssignment);
|
||||
}
|
||||
}
|
||||
|
||||
processed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ public class LdnTermsConverter extends AbstractConverter {
|
|||
*/
|
||||
@Override
|
||||
public void startConversionToNg() {
|
||||
DomainConversion.convertAll();
|
||||
ResourceTypeConversion.convertAll();
|
||||
CcmApplicationConversion.convertAll();
|
||||
DomainConversion.convertAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
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.categorization.DomainOwnership;
|
||||
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;
|
||||
|
|
@ -31,12 +32,13 @@ import java.util.Map;
|
|||
* @version created the 7/28/17
|
||||
*/
|
||||
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<>();
|
||||
|
||||
public static Map<Long, Domain> domains = new HashMap<>();
|
||||
public static Map<Long, DomainOwnership> domainOwnerships = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Private constructor to prevent the instantiation of this class.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,9 +18,16 @@
|
|||
*/
|
||||
package com.arsdigita.london.terms.portation.conversion.core.categorization;
|
||||
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
|
||||
import com.arsdigita.london.terms.portation.modules.core.categorization.Domain;
|
||||
import com.arsdigita.portation.conversion.NgCoreCollection;
|
||||
import com.arsdigita.london.terms.portation.modules.core.categorization.DomainOwnership;
|
||||
import com.arsdigita.london.terms.portation.modules.core.web.CcmApplication;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.portation.modules.core.categorization.Category;
|
||||
import com.arsdigita.web.Application;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -46,7 +53,7 @@ public class DomainConversion {
|
|||
.arsdigita.london.terms.Domain.getAllObjectDomains();
|
||||
System.err.println("done.");
|
||||
|
||||
System.err.printf("\tConverting domains...\n");
|
||||
System.err.printf("\tConverting domains and domain ownerships...\n");
|
||||
createDomainsAndSetAssociations(trunkDomains);
|
||||
System.err.printf("\tdone.\n");
|
||||
}
|
||||
|
|
@ -60,26 +67,78 @@ public class DomainConversion {
|
|||
*/
|
||||
private static void createDomainsAndSetAssociations(
|
||||
List<com.arsdigita.london.terms.Domain> trunkDomains) {
|
||||
long processed = 0;
|
||||
long processedDomains = 0, processedDomainOwnerships = 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
|
||||
com.arsdigita.categorization.Category trunkModel = trunkDomain
|
||||
.getModel();
|
||||
if (model != null) {
|
||||
Category root = NgCoreCollection
|
||||
if (trunkModel != null) {
|
||||
Category root = com.arsdigita.portation.conversion
|
||||
.NgCoreCollection
|
||||
.categories
|
||||
.get(model.getID().longValue());
|
||||
.get(trunkModel.getID().longValue());
|
||||
domain.setRoot(root);
|
||||
}
|
||||
|
||||
processed++;
|
||||
// create domain ownerships
|
||||
DomainCollection useContexts = trunkDomain.getUseContexts();
|
||||
processedDomainOwnerships += createDomainOwnerships(domain,
|
||||
useContexts);
|
||||
|
||||
processedDomains++;
|
||||
}
|
||||
System.err.printf("\t\tCreated %d domains and %d domain ownerships.\n",
|
||||
processedDomains, processedDomainOwnerships);
|
||||
}
|
||||
|
||||
System.err.printf("\t\tCreated %d domains.\n", processed);
|
||||
/**
|
||||
* Method for creating {@link DomainOwnership}s between {@link Domain}s
|
||||
* and {@link CcmApplication}s which is an association-class and has not
|
||||
* been existent in this old system.
|
||||
*
|
||||
* @param domain The {@link Domain}
|
||||
* @param useContexts A collection containing the {@code owner}s of the
|
||||
* {@link Domain} and its {@code context}
|
||||
*
|
||||
* @return Number of how many {@link DomainOwnership}s have been processed.
|
||||
*/
|
||||
private static long createDomainOwnerships(Domain domain,
|
||||
DomainCollection useContexts) {
|
||||
long processed = 0;
|
||||
|
||||
while (useContexts.next()) {
|
||||
final DomainObject obj = DomainObjectFactory
|
||||
.newInstance((DataObject) useContexts
|
||||
.getDomainObject()
|
||||
.get("categoryOwner"));
|
||||
if (obj instanceof Application) {
|
||||
CcmApplication owner = NgCoreCollection
|
||||
.ccmApplications
|
||||
.get(((Application) obj)
|
||||
.getID()
|
||||
.longValue());
|
||||
String context = (String) useContexts
|
||||
.getDomainObject()
|
||||
.get("useContext");
|
||||
|
||||
if (domain != null && owner != null) {
|
||||
// create domain ownerships
|
||||
DomainOwnership domainOwnership = new DomainOwnership(domain,
|
||||
owner, context);
|
||||
|
||||
// set opposed associations
|
||||
domain.addOwner(domainOwnership);
|
||||
owner.addDomain(domainOwnership);
|
||||
|
||||
processed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ import com.arsdigita.london.terms.portation.modules.core.core.ResourceType;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class for converting all trunk-{@link com.arsdigita.kernel.ResourceType}s
|
||||
* into ng-{@link ResourceType}s as preparation for a successful export of
|
||||
* all trunk classes into the new ng-system.
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/2/17
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ import com.arsdigita.web.Application;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class for converting all trunk-{@link Application}s into
|
||||
* ng-{@link CcmApplication}s as preparation for a successful export of all
|
||||
* trunkclasses into the new ng-system.
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/2/17
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package com.arsdigita.london.terms.portation.modules;
|
||||
|
||||
import com.arsdigita.london.terms.portation.conversion.NgCoreCollection;
|
||||
import com.arsdigita.london.terms.portation.modules.core.categorization.DomainOwnershipMarshaller;
|
||||
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;
|
||||
|
|
@ -43,6 +44,7 @@ public class LdnTermsExporter extends AbstractExporter {
|
|||
exportDomains();
|
||||
exportResourceTypes();
|
||||
exportCcmApplications();
|
||||
exportDomainOwnerships();
|
||||
}
|
||||
|
||||
private static void exportDomains() {
|
||||
|
|
@ -76,4 +78,15 @@ public class LdnTermsExporter extends AbstractExporter {
|
|||
new ArrayList<>(NgCoreCollection.ccmApplications.values()));
|
||||
System.out.printf("\tdone.\n");
|
||||
}
|
||||
|
||||
private static void exportDomainOwnerships() {
|
||||
System.out.printf("\tExporting domain ownerships...");
|
||||
DomainOwnershipMarshaller domainOwnershipMarshaller = new
|
||||
DomainOwnershipMarshaller();
|
||||
domainOwnershipMarshaller.prepare(
|
||||
Format.XML, pathName, "domainOwnerships", indentation);
|
||||
domainOwnershipMarshaller.exportList(
|
||||
new ArrayList<>(NgCoreCollection.domainOwnerships.values()));
|
||||
System.out.printf("\tdone.\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,4 +150,12 @@ public class Domain extends CcmObject implements Portable {
|
|||
public void setOwners(final List<DomainOwnership> owners) {
|
||||
this.owners = owners;
|
||||
}
|
||||
|
||||
public void addOwner(final DomainOwnership owner) {
|
||||
this.owners.add(owner);
|
||||
}
|
||||
|
||||
public void removeOwner(final DomainOwnership owner) {
|
||||
this.owners.remove(owner);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +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.core.CcmObject;
|
||||
import com.arsdigita.web.Application;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
|
||||
/**
|
||||
* Association class for the association between a {@link Domain} and a
|
||||
|
|
@ -31,22 +36,34 @@ import com.arsdigita.web.Application;
|
|||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 7/27/17
|
||||
*/
|
||||
public class DomainOwnership {
|
||||
@JsonIdentityInfo(generator = DomainOwnershipIdGenerator.class,
|
||||
property = "customOwnId")
|
||||
public class DomainOwnership implements Portable {
|
||||
|
||||
private long ownershipId;
|
||||
private CcmApplication owner;
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private Domain domain;
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private CcmApplication owner;
|
||||
private String context;
|
||||
private long ownerOrder;
|
||||
private long domainOrder;
|
||||
|
||||
public DomainOwnership() {
|
||||
public DomainOwnership(Domain domain, CcmApplication owner, String
|
||||
context) {
|
||||
this.ownershipId = ACSObject.generateID().longValue();
|
||||
|
||||
this.domain = domain;
|
||||
this.owner = owner;
|
||||
|
||||
this.context = context;
|
||||
this.ownerOrder = 1;
|
||||
this.domainOrder = 1;
|
||||
|
||||
NgCoreCollection.domainOwnerships.put(this.getOwnershipId(), this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public long getOwnershipId() {
|
||||
return ownershipId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/9/17
|
||||
*/
|
||||
public class DomainOwnershipIdGenerator extends ObjectIdGenerator<String> {
|
||||
@Override
|
||||
public Class<?> getScope() {
|
||||
return DomainOwnership.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseFor(ObjectIdGenerator gen) {
|
||||
return gen instanceof DomainOwnershipIdGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdGenerator<String> forScope(Class aClass) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdGenerator<String> newForSerialization(Object gen) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdKey key(Object key) {
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
return new IdKey(DomainOwnership.class, DomainOwnership.class, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateId(Object forPojo) {
|
||||
if (!(forPojo instanceof DomainOwnership)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Only DomainOwnership instances are supported.");
|
||||
}
|
||||
|
||||
final DomainOwnership ownership = (DomainOwnership) forPojo;
|
||||
|
||||
return String.format("{%s}{%s}",
|
||||
ownership.getDomain().getDomainKey(),
|
||||
ownership.getOwner().getPrimaryUrl());
|
||||
}
|
||||
}
|
||||
|
|
@ -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.categorization;
|
||||
|
||||
import com.arsdigita.portation.AbstractMarshaller;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/10/17
|
||||
*/
|
||||
public class DomainOwnershipMarshaller extends AbstractMarshaller<DomainOwnership>{
|
||||
}
|
||||
|
|
@ -80,4 +80,12 @@ public class CcmApplication extends Resource implements Portable {
|
|||
public void setDomains(final List<DomainOwnership> domains) {
|
||||
this.domains = domains;
|
||||
}
|
||||
|
||||
public void addDomain(final DomainOwnership domain) {
|
||||
this.domains.add(domain);
|
||||
}
|
||||
|
||||
public void removeDomain(final DomainOwnership domain) {
|
||||
this.domains.remove(domain);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,8 +129,9 @@ public class DomainMappingTable extends Table implements TableActionListener {
|
|||
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
final DomainObject obj = DomainObjectFactory.newInstance((DataObject) get(
|
||||
useContexts.getDomainObject(), "categoryOwner"));
|
||||
final DomainObject obj = DomainObjectFactory
|
||||
.newInstance((DataObject) get(useContexts
|
||||
.getDomainObject(), "categoryOwner"));
|
||||
if (obj instanceof Application) {
|
||||
return ((Application) obj).getPath();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue