- removes Marshaller Instances for classes which are not meant to be exported
- renames interface Identifiable to Portable

git-svn-id: https://svn.libreccm.org/ccm/trunk@4430 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2016-11-07 18:41:36 +00:00
parent 10f748d5d6
commit d62cafc077
24 changed files with 103 additions and 217 deletions

View File

@ -39,7 +39,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 2/10/16 * @version created on 2/10/16
*/ */
public abstract class AbstractMarshaller<I extends Identifiable> { public abstract class AbstractMarshaller<P extends Portable> {
private static final Logger log = Logger.getLogger(AbstractMarshaller.class); private static final Logger log = Logger.getLogger(AbstractMarshaller.class);
@ -78,7 +78,7 @@ public abstract class AbstractMarshaller<I extends Identifiable> {
} }
} }
public void exportList(final List<I> exportList) { public void exportList(final List<P> exportList) {
File file = new File(filename); File file = new File(filename);
FileWriter fileWriter = null; FileWriter fileWriter = null;
@ -89,7 +89,7 @@ public abstract class AbstractMarshaller<I extends Identifiable> {
" with the name %s.", file.getName())); " with the name %s.", file.getName()));
} }
if (fileWriter != null) { if (fileWriter != null) {
for (I object : exportList) { for (P object : exportList) {
String line = null; String line = null;
switch (format) { switch (format) {

View File

@ -40,7 +40,7 @@ public class Marshaller {
// Assigns lists with objects of the same type as values to their typ as // Assigns lists with objects of the same type as values to their typ as
// key. // key.
private Map<Class<? extends Identifiable>, List<Identifiable>> classListMap = new HashMap<>(); private Map<Class<? extends Portable>, List<Portable>> classListMap = new HashMap<>();
/** /**
@ -51,11 +51,11 @@ public class Marshaller {
* @param format The exportUsers style/format e.g. CSV or JSON * @param format The exportUsers style/format e.g. CSV or JSON
* @param filename The name of the file to be exported to * @param filename The name of the file to be exported to
*/ */
public void exportObjects(List<? extends Identifiable> objects, Format format, public void exportObjects(List<? extends Portable> objects, Format format,
String filename) { String filename) {
putObjects(objects); putObjects(objects);
for (Map.Entry<Class<? extends Identifiable>, List<Identifiable>> for (Map.Entry<Class<? extends Portable>, List<Portable>>
classListEntry : classListMap.entrySet()) { classListEntry : classListMap.entrySet()) {
exportList(classListEntry.getValue(), classListEntry.getKey(), exportList(classListEntry.getValue(), classListEntry.getKey(),
@ -64,7 +64,7 @@ public class Marshaller {
} }
/** /**
* Organizes a list of different {@link Identifiable} objects into a map * 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 * 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. * 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 * That opens the possibility of being certain of the objects types in
@ -72,14 +72,14 @@ public class Marshaller {
* *
* @param objects list of all objects being organized * @param objects list of all objects being organized
*/ */
private void putObjects(List<? extends Identifiable> objects) { private void putObjects(List<? extends Portable> objects) {
for (Identifiable object : objects) { for (Portable object : objects) {
Class<? extends Identifiable> type = object.getClass(); Class<? extends Portable> type = object.getClass();
if (classListMap.containsKey(type)) { if (classListMap.containsKey(type)) {
classListMap.get(type).add(object); classListMap.get(type).add(object);
} else { } else {
List<Identifiable> values = new ArrayList<>(); List<Portable> values = new ArrayList<>();
values.add(object); values.add(object);
classListMap.put(type, values); classListMap.put(type, values);
} }
@ -98,12 +98,12 @@ public class Marshaller {
* @param type The class of the type * @param type The class of the type
* @param format The exportUsers style * @param format The exportUsers style
* @param filename The filename * @param filename The filename
* @param <I> The type of the current marshaller * @param <P> The type of the current marshaller
*/ */
private <I extends Identifiable> void exportList(List<I> list, Class<? private <P extends Portable> void exportList(List<P> list, Class<?
extends I> type, Format format, String filename) { extends P> type, Format format, String filename) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
AbstractMarshaller<I> marshaller = (AbstractMarshaller<I>) list.get AbstractMarshaller<P> marshaller = (AbstractMarshaller<P>) list.get
(0).getMarshaller(); (0).getMarshaller();
marshaller.prepare(format, filename + "__" + type.toString(), marshaller.prepare(format, filename + "__" + type.toString(),

View File

@ -22,7 +22,7 @@ package com.arsdigita.portation;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 5/9/16 * @version created on 5/9/16
*/ */
public interface Identifiable { public interface Portable {
AbstractMarshaller<? extends Identifiable> getMarshaller(); AbstractMarshaller<? extends Portable> getMarshaller();
} }

View File

@ -44,12 +44,13 @@ import java.util.ArrayList;
class ExportHelper { class ExportHelper {
private static String pathName = "/home/tosmers/Downloads/test-exports"; private static String pathName = "/home/tosmers/Downloads/test-exports";
private static boolean indentation = false;
static void exportCategories() { static void exportCategories() {
CategoryMarshaller categoryMarshaller = new CategoryMarshaller categoryMarshaller = new
CategoryMarshaller(); CategoryMarshaller();
categoryMarshaller.prepare(Format.XML, pathName, categoryMarshaller.prepare(Format.XML, pathName,
"categories", true); "categories", indentation);
categoryMarshaller.exportList(new ArrayList<>( categoryMarshaller.exportList(new ArrayList<>(
NgCollection.categories.values())); NgCollection.categories.values()));
} }
@ -58,22 +59,23 @@ class ExportHelper {
CategorizationMarshaller categorizationMarshaller = new CategorizationMarshaller categorizationMarshaller = new
CategorizationMarshaller(); CategorizationMarshaller();
categorizationMarshaller.prepare(Format.XML, pathName, categorizationMarshaller.prepare(Format.XML, pathName,
"categorizations", true); "categorizations", indentation);
categorizationMarshaller.exportList(new ArrayList<>( categorizationMarshaller.exportList(new ArrayList<>(
NgCollection.categorizations.values())); NgCollection.categorizations.values()));
} }
static void exportUsers() { static void exportUsers() {
UserMarshaller userMarshaller = new UserMarshaller(); UserMarshaller userMarshaller = new UserMarshaller();
userMarshaller.prepare(Format.XML, pathName, "users", true); userMarshaller.prepare(Format.XML, pathName,
"users", indentation);
userMarshaller.exportList(new ArrayList<>( userMarshaller.exportList(new ArrayList<>(
NgCollection.users.values())); NgCollection.users.values()));
} }
static void exportGroups() { static void exportGroups() {
GroupMarshaller groupMarshaller = new GroupMarshaller(); GroupMarshaller groupMarshaller = new GroupMarshaller();
groupMarshaller.prepare(Format.XML, pathName, "groups", groupMarshaller.prepare(Format.XML, pathName,
true); "groups", indentation);
groupMarshaller.exportList(new ArrayList<>( groupMarshaller.exportList(new ArrayList<>(
NgCollection.groups.values())); NgCollection.groups.values()));
} }
@ -82,14 +84,15 @@ class ExportHelper {
GroupMembershipMarshaller groupMembershipMarshaller = new GroupMembershipMarshaller groupMembershipMarshaller = new
GroupMembershipMarshaller(); GroupMembershipMarshaller();
groupMembershipMarshaller.prepare(Format.XML, pathName, groupMembershipMarshaller.prepare(Format.XML, pathName,
"groupMemberships", true); "groupMemberships", indentation);
groupMembershipMarshaller.exportList(new ArrayList<>( groupMembershipMarshaller.exportList(new ArrayList<>(
NgCollection.groupMemberships.values())); NgCollection.groupMemberships.values()));
} }
static void exportRoles() { static void exportRoles() {
RoleMarshaller roleMarshaller = new RoleMarshaller(); RoleMarshaller roleMarshaller = new RoleMarshaller();
roleMarshaller.prepare(Format.XML, pathName, "roles", true); roleMarshaller.prepare(Format.XML, pathName,
"roles", indentation);
roleMarshaller.exportList(new ArrayList<>(NgCollection roleMarshaller.exportList(new ArrayList<>(NgCollection
.roles.values())); .roles.values()));
} }
@ -98,7 +101,7 @@ class ExportHelper {
RoleMembershipMarshaller roleMembershipMarshaller = new RoleMembershipMarshaller roleMembershipMarshaller = new
RoleMembershipMarshaller(); RoleMembershipMarshaller();
roleMembershipMarshaller.prepare(Format.XML, pathName, roleMembershipMarshaller.prepare(Format.XML, pathName,
"roleMemberships", true); "roleMemberships", indentation);
roleMembershipMarshaller.exportList(new ArrayList<> roleMembershipMarshaller.exportList(new ArrayList<>
(NgCollection.roleMemberships.values())); (NgCollection.roleMemberships.values()));
} }
@ -107,7 +110,7 @@ class ExportHelper {
WorkflowMarshaller workflowMarshaller = new WorkflowMarshaller workflowMarshaller = new
WorkflowMarshaller(); WorkflowMarshaller();
workflowMarshaller.prepare(Format.XML, pathName, workflowMarshaller.prepare(Format.XML, pathName,
"workflows", true); "workflows", indentation);
workflowMarshaller.exportList(new ArrayList<> workflowMarshaller.exportList(new ArrayList<>
(NgCollection.workflows.values())); (NgCollection.workflows.values()));
} }
@ -116,7 +119,7 @@ class ExportHelper {
UserTaskMarshaller userTaskMarshaller = new UserTaskMarshaller userTaskMarshaller = new
UserTaskMarshaller(); UserTaskMarshaller();
userTaskMarshaller.prepare(Format.XML, pathName, userTaskMarshaller.prepare(Format.XML, pathName,
"userTasks", true); "userTasks", indentation);
userTaskMarshaller.exportList(new ArrayList<> userTaskMarshaller.exportList(new ArrayList<>
(NgCollection.userTasks.values())); (NgCollection.userTasks.values()));
} }
@ -125,7 +128,7 @@ class ExportHelper {
TaskAssignmentMarshaller taskAssignmentMarshaller = new TaskAssignmentMarshaller taskAssignmentMarshaller = new
TaskAssignmentMarshaller(); TaskAssignmentMarshaller();
taskAssignmentMarshaller.prepare(Format.XML, pathName, taskAssignmentMarshaller.prepare(Format.XML, pathName,
"taskAssignments", true); "taskAssignments", indentation);
taskAssignmentMarshaller.exportList(new ArrayList<> taskAssignmentMarshaller.exportList(new ArrayList<>
(NgCollection.taskAssignments.values())); (NgCollection.taskAssignments.values()));
} }
@ -134,7 +137,7 @@ class ExportHelper {
PermissionMarshaller permissionMarshaller = new PermissionMarshaller permissionMarshaller = new
PermissionMarshaller(); PermissionMarshaller();
permissionMarshaller.prepare(Format.XML, pathName, permissionMarshaller.prepare(Format.XML, pathName,
"permissions", true); "permissions", indentation);
permissionMarshaller.exportList(new ArrayList<> permissionMarshaller.exportList(new ArrayList<>
(NgCollection.permissions.values())); (NgCollection.permissions.values()));
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.categorization; package com.arsdigita.portation.modules.core.categorization;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.core.CcmObject;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonBackReference;
@ -32,7 +32,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class Categorization implements Identifiable { public class Categorization implements Portable {
private long categorizationId; private long categorizationId;
@ -45,6 +45,8 @@ public class Categorization implements Identifiable {
private long categoryOrder; private long categoryOrder;
private long objectOrder; private long objectOrder;
private String type;
public Categorization(final Category category, final CcmObject public Categorization(final Category category, final CcmObject
categorizedObject) { categorizedObject) {
this.categorizationId = NgCollection.categorizations.size() + 1; this.categorizationId = NgCollection.categorizations.size() + 1;
@ -56,12 +58,14 @@ public class Categorization implements Identifiable {
this.categoryOrder = categorizedObject.getCategories().size() + 1; this.categoryOrder = categorizedObject.getCategories().size() + 1;
this.objectOrder = category.getObjects().size() + 1; this.objectOrder = category.getObjects().size() + 1;
this.type = "";
NgCollection.categorizations.put(this.categorizationId, this); NgCollection.categorizations.put(this.categorizationId, this);
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new CategorizationMarshaller(); return new CategorizationMarshaller();
} }
@ -112,4 +116,12 @@ public class Categorization implements Identifiable {
public void setObjectOrder(final long objectOrder) { public void setObjectOrder(final long objectOrder) {
this.objectOrder = objectOrder; this.objectOrder = objectOrder;
} }
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
} }

View File

@ -21,7 +21,7 @@ package com.arsdigita.portation.modules.core.categorization;
import com.arsdigita.categorization.CategoryLocalization; import com.arsdigita.categorization.CategoryLocalization;
import com.arsdigita.categorization.CategoryLocalizationCollection; import com.arsdigita.categorization.CategoryLocalizationCollection;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.l10n.LocalizedString;
@ -112,7 +112,7 @@ public class Category extends CcmObject {
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new CategoryMarshaller(); return new CategoryMarshaller();
} }

View File

@ -20,7 +20,7 @@ package com.arsdigita.portation.modules.core.core;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.categorization.Categorization; import com.arsdigita.portation.modules.core.categorization.Categorization;
import com.arsdigita.portation.modules.core.categorization.Category; import com.arsdigita.portation.modules.core.categorization.Category;
@ -48,7 +48,7 @@ import java.util.UUID;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class CcmObject implements Identifiable { public class CcmObject implements Portable {
private long objectId; private long objectId;
@ -74,7 +74,7 @@ public class CcmObject implements Identifiable {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new CcmObjectMarshaller(); return new CcmObjectMarshaller();
} }

View File

@ -18,14 +18,11 @@
*/ */
package com.arsdigita.portation.modules.core.core; package com.arsdigita.portation.modules.core.core;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable;
/** /**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class EmailAddress implements Identifiable { public class EmailAddress {
private String address; private String address;
@ -40,11 +37,6 @@ public class EmailAddress implements Identifiable {
this.verified = trunkEmailAddress.isVerified(); this.verified = trunkEmailAddress.isVerified();
} }
@Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() {
return new EmailAddressMarshaller();
}
public String getAddress() { public String getAddress() {
return address; return address;
} }

View File

@ -1,28 +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.modules.core.core;
import com.arsdigita.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class EmailAddressMarshaller extends AbstractMarshaller<EmailAddress> {
}

View File

@ -18,9 +18,6 @@
*/ */
package com.arsdigita.portation.modules.core.l10n; package com.arsdigita.portation.modules.core.l10n;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
@ -36,7 +33,7 @@ import java.util.Set;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class LocalizedString implements Identifiable { public class LocalizedString {
private Map<Locale, String> values; private Map<Locale, String> values;
@ -47,11 +44,6 @@ public class LocalizedString implements Identifiable {
this.values = new HashMap<>(); this.values = new HashMap<>();
} }
@Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() {
return new LocalizedStringMarshaller();
}
/** /**
* Get all localised values. * Get all localised values.
* *

View File

@ -1,28 +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.modules.core.l10n;
import com.arsdigita.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class LocalizedStringMarshaller extends AbstractMarshaller<LocalizedString> {
}

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
@ -30,7 +30,7 @@ import java.util.Set;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 31.05.16 * @version created on 31.05.16
*/ */
public class Group extends Party { public class Group extends Party implements Portable {
@JsonManagedReference @JsonManagedReference
private Set<GroupMembership> memberships; private Set<GroupMembership> memberships;
@ -44,7 +44,7 @@ public class Group extends Party {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new GroupMarshaller(); return new GroupMarshaller();
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonBackReference;
@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class GroupMembership implements Identifiable { public class GroupMembership implements Portable {
private long membershipId; private long membershipId;
@ -46,7 +46,7 @@ public class GroupMembership implements Identifiable {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new GroupMembershipMarshaller(); return new GroupMembershipMarshaller();
} }

View File

@ -18,8 +18,6 @@
*/ */
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
@ -30,7 +28,7 @@ import java.util.Set;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 01.06.16 * @version created on 01.06.16
*/ */
public class Party implements Identifiable { public class Party {
private long partyId; private long partyId;
private String name; private String name;
@ -47,11 +45,6 @@ public class Party implements Identifiable {
NgCollection.parties.put(this.partyId, this); NgCollection.parties.put(this.partyId, this);
} }
@Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() {
return new PartyMarshaller();
}
public long getPartyId() { public long getPartyId() {
return partyId; return partyId;
} }

View File

@ -1,28 +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.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 01.06.16
*/
public class PartyMarshaller extends AbstractMarshaller<Party> {
}

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.security.util.PermissionIdMapper; import com.arsdigita.portation.modules.core.security.util.PermissionIdMapper;
@ -32,7 +32,7 @@ import java.util.Date;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class Permission implements Identifiable { public class Permission implements Portable {
private long permissionId; private long permissionId;
private String grantedPrivilege; private String grantedPrivilege;
@ -89,7 +89,7 @@ public class Permission implements Identifiable {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new PermissionMarshaller(); return new PermissionMarshaller();
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.workflow.TaskAssignment; import com.arsdigita.portation.modules.core.workflow.TaskAssignment;
@ -35,50 +35,52 @@ import java.util.Set;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class Role implements Identifiable { public class Role implements Portable {
private long roleId; private long roleId;
private String name; private String name;
private LocalizedString description;
@JsonManagedReference @JsonManagedReference
private Set<RoleMembership> memberships; private Set<RoleMembership> memberships;
@JsonManagedReference @JsonManagedReference
private List<Permission> permissions; private List<Permission> permissions;
@JsonManagedReference @JsonManagedReference
private List<TaskAssignment> assignedTasks; private List<TaskAssignment> assignedTasks;
private LocalizedString description;
public Role(final com.arsdigita.kernel.Role trunkRole) { public Role(final com.arsdigita.kernel.Role trunkRole) {
this.roleId = trunkRole.getID().longValue(); this.roleId = trunkRole.getID().longValue();
this.name = trunkRole.getName(); this.name = trunkRole.getName();
Locale local = Locale.getDefault();
this.description = new LocalizedString();
this.description.addValue(local, trunkRole.getDescription());
this.memberships = new HashSet<>(); this.memberships = new HashSet<>();
this.permissions = new ArrayList<>(); this.permissions = new ArrayList<>();
this.assignedTasks = new ArrayList<>(); this.assignedTasks = new ArrayList<>();
Locale local = Locale.getDefault();
this.description = new LocalizedString();
this.description.addValue(local, trunkRole.getDescription());
NgCollection.roles.put(this.roleId, this); NgCollection.roles.put(this.roleId, this);
} }
public Role(final String name) { public Role(final String name) {
this.roleId = NgCollection.roles.size() + 1; this.roleId = NgCollection.roles.size() + 1;
this.name = name; this.name = name;
this.description = new LocalizedString();
this.memberships = new HashSet<>(); this.memberships = new HashSet<>();
this.permissions = new ArrayList<>(); this.permissions = new ArrayList<>();
this.assignedTasks = new ArrayList<>(); this.assignedTasks = new ArrayList<>();
this.description = new LocalizedString();
NgCollection.roles.put(this.roleId, this); NgCollection.roles.put(this.roleId, this);
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new RoleMarshaller(); return new RoleMarshaller();
} }
@ -145,4 +147,12 @@ public class Role implements Identifiable {
public void removeAssignedTask(final TaskAssignment taskAssignment) { public void removeAssignedTask(final TaskAssignment taskAssignment) {
assignedTasks.remove(taskAssignment); assignedTasks.remove(taskAssignment);
} }
public LocalizedString getDescription() {
return description;
}
public void setDescription(final LocalizedString description) {
this.description = description;
}
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonBackReference;
@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class RoleMembership implements Identifiable { public class RoleMembership implements Portable {
private long membershipId; private long membershipId;
@ -46,7 +46,7 @@ public class RoleMembership implements Identifiable {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new RoleMembershipMarshaller(); return new RoleMembershipMarshaller();
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.security; package com.arsdigita.portation.modules.core.security;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.core.EmailAddress; import com.arsdigita.portation.modules.core.core.EmailAddress;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
@ -34,7 +34,7 @@ import java.util.Set;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 31.05.16 * @version created on 31.05.16
*/ */
public class User extends Party { public class User extends Party implements Portable {
private String givenName; private String givenName;
private String familyName; private String familyName;
@ -74,7 +74,7 @@ public class User extends Party {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new UserMarshaller(); return new UserMarshaller();
} }

View File

@ -18,8 +18,6 @@
*/ */
package com.arsdigita.portation.modules.core.workflow; package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonBackReference;
@ -34,7 +32,7 @@ import java.util.Locale;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class Task implements Identifiable { public class Task {
private long taskId; private long taskId;
private LocalizedString label; private LocalizedString label;
@ -50,6 +48,7 @@ public class Task implements Identifiable {
private List<Task> dependentTasks; private List<Task> dependentTasks;
@JsonManagedReference @JsonManagedReference
private List<Task> dependsOn; private List<Task> dependsOn;
private List<String> comments; private List<String> comments;
public Task(final com.arsdigita.workflow.simple.Task trunkTask) { public Task(final com.arsdigita.workflow.simple.Task trunkTask) {
@ -76,11 +75,6 @@ public class Task implements Identifiable {
NgCollection.tasks.put(this.getTaskId(), this); NgCollection.tasks.put(this.getTaskId(), this);
} }
@Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() {
return new TaskMarshaller();
}
public long getTaskId() { public long getTaskId() {
return taskId; return taskId;
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.workflow; package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.security.Role; import com.arsdigita.portation.modules.core.security.Role;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonBackReference;
@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class TaskAssignment implements Identifiable { public class TaskAssignment implements Portable {
private long taskAssignmentId; private long taskAssignmentId;
@ -47,7 +47,7 @@ public class TaskAssignment implements Identifiable {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new TaskAssignmentMarshaller(); return new TaskAssignmentMarshaller();
} }

View File

@ -1,28 +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.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
*/
public class TaskMarshaller extends AbstractMarshaller<Task> {
}

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.workflow; package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.security.User; import com.arsdigita.portation.modules.core.security.User;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
@ -32,7 +32,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class UserTask extends Task { public class UserTask extends Task implements Portable {
private boolean locked; private boolean locked;
private User lockingUser; private User lockingUser;
@ -65,7 +65,7 @@ public class UserTask extends Task {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new UserTaskMarshaller(); return new UserTaskMarshaller();
} }

View File

@ -19,7 +19,7 @@
package com.arsdigita.portation.modules.core.workflow; package com.arsdigita.portation.modules.core.workflow;
import com.arsdigita.portation.AbstractMarshaller; import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Identifiable; import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCollection; import com.arsdigita.portation.conversion.NgCollection;
import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
@ -32,13 +32,15 @@ import java.util.Locale;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a> * @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16 * @version created on 6/15/16
*/ */
public class Workflow implements Identifiable { public class Workflow implements Portable {
private long workflowId; private long workflowId;
private LocalizedString name; private LocalizedString name;
private LocalizedString description; private LocalizedString description;
//Todo: private WorkflowTemplate workflowTemplate;
@JsonManagedReference @JsonManagedReference
private List<Task> tasks; private List<Task> tasks;
@ -56,7 +58,7 @@ public class Workflow implements Identifiable {
} }
@Override @Override
public AbstractMarshaller<? extends Identifiable> getMarshaller() { public AbstractMarshaller<? extends Portable> getMarshaller() {
return new WorkflowMarshaller(); return new WorkflowMarshaller();
} }