adds converter methods for converting workflow, category and task objects from trunk-POJOs into NG-POJOs; adds retrieveAll method for workflow objects
git-svn-id: https://svn.libreccm.org/ccm/trunk@4178 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
676b3be133
commit
aa0a3f8838
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.portation.cmd;
|
|
||||||
|
|
||||||
import com.arsdigita.portation.Format;
|
|
||||||
import com.arsdigita.portation.modules.core.security.Group;
|
|
||||||
import com.arsdigita.portation.modules.core.security.GroupMarshaller;
|
|
||||||
import com.arsdigita.portation.modules.core.security.Party;
|
|
||||||
import com.arsdigita.portation.modules.core.security.PartyMarshaller;
|
|
||||||
import com.arsdigita.portation.modules.core.security.User;
|
|
||||||
import com.arsdigita.portation.modules.core.security.UserMarshaller;
|
|
||||||
import com.arsdigita.portation.modules.utils.CollectionConverter;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
|
||||||
* @version created the 25.05.16
|
|
||||||
*/
|
|
||||||
class CoreExport {
|
|
||||||
private final static Logger logger = Logger.getLogger(CoreExport.class);
|
|
||||||
|
|
||||||
private static List<Party> parties = new ArrayList<>();
|
|
||||||
private static List<User> users = new ArrayList<>();
|
|
||||||
private static List<Group> groups = new ArrayList<>();
|
|
||||||
|
|
||||||
static void retrieveParties() {
|
|
||||||
System.out.println("\n...0...\n");
|
|
||||||
parties = CollectionConverter.convertParties(com.arsdigita.kernel.Party.retrieveAllParties());
|
|
||||||
}
|
|
||||||
static void exportParties() {
|
|
||||||
PartyMarshaller partyMarshaller = new PartyMarshaller();
|
|
||||||
partyMarshaller.prepare(Format.XML, "PortationTestFiles", "partyExport_test01", true);
|
|
||||||
partyMarshaller.exportList(parties);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void retrieveUsers() {
|
|
||||||
System.out.println("\n...1...\n");
|
|
||||||
users = CollectionConverter.convertUsers(com.arsdigita.kernel.User.retrieveAll());
|
|
||||||
}
|
|
||||||
static void exportUsers() {
|
|
||||||
UserMarshaller userMarshaller = new UserMarshaller();
|
|
||||||
userMarshaller.prepare(Format.XML, "PortationTestFiles", "userExport_test01", true);
|
|
||||||
userMarshaller.exportList(users);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void retrieveGroups() {
|
|
||||||
System.out.println("\n...2...\n");
|
|
||||||
groups = CollectionConverter.convertGroups(com.arsdigita.kernel.Group.retrieveAll());
|
|
||||||
}
|
|
||||||
static void exportGroups() {
|
|
||||||
GroupMarshaller groupMarshaller = new GroupMarshaller();
|
|
||||||
groupMarshaller.prepare(Format.XML, "PortationTestFiles", "groupExport_test01", true);
|
|
||||||
groupMarshaller.exportList(groups);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -50,6 +50,7 @@ public class ExportCliTool extends Program {
|
||||||
printUsage();
|
printUsage();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String command = args[0];
|
final String command = args[0];
|
||||||
System.out.printf("\nCommand is %s\n", command);
|
System.out.printf("\nCommand is %s\n", command);
|
||||||
|
|
||||||
|
|
@ -57,9 +58,11 @@ public class ExportCliTool extends Program {
|
||||||
case "help":
|
case "help":
|
||||||
printUsage();
|
printUsage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "export":
|
case "export":
|
||||||
export(args);
|
export(args);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printUsage();
|
printUsage();
|
||||||
break;
|
break;
|
||||||
|
|
@ -71,31 +74,12 @@ public class ExportCliTool extends Program {
|
||||||
printUsage();
|
printUsage();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String category = args[1];
|
final String category = args[1];
|
||||||
System.out.printf("\nCategory is %s\n", category);
|
System.out.printf("\nCategory is %s\n", category);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case "parties":
|
|
||||||
System.out.printf("\nStarting export of all parties...\n\n");
|
|
||||||
CoreExport.retrieveParties();
|
|
||||||
CoreExport.exportParties();
|
|
||||||
System.out.printf("\n...done!\n\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "users":
|
|
||||||
System.out.printf("\nStarting export of all users...\n\n");
|
|
||||||
CoreExport.retrieveUsers();
|
|
||||||
CoreExport.exportUsers();
|
|
||||||
System.out.printf("\n...done!\n\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "groups":
|
|
||||||
System.out.printf("\nStarting export of all groups...\n\n");
|
|
||||||
CoreExport.retrieveGroups();
|
|
||||||
CoreExport.exportGroups();
|
|
||||||
System.out.printf("\n...done!\n\n");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printUsage();
|
printUsage();
|
||||||
|
|
@ -108,17 +92,17 @@ public class ExportCliTool extends Program {
|
||||||
|
|
||||||
private void printUsage() {
|
private void printUsage() {
|
||||||
System.err.printf(
|
System.err.printf(
|
||||||
"\t\t\t--- ExportCliTool ---\n" +
|
"\t\t\t--- ExportCliTool ---\n" +
|
||||||
"usage:\t<command> [<category>]\n" +
|
"usage:\t<command> [<category>]\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Available commands:\n" +
|
"Available commands:\n" +
|
||||||
"\tlist \t\t Shows information on how to use this tool.\n" +
|
"\tlist \t\t Shows information on how to use this tool.\n" +
|
||||||
"\texportUsers <category> \t\t Exports the chosen category to xml file.\n" +
|
"\texportUsers <category> \t\t Exports the chosen category to xml file.\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Available categories for exportUsers:\n" +
|
"Available categories for exportUsers:\n" +
|
||||||
" \t\t users \t all users of the system\n" +
|
" \t\t users \t all users of the system\n" +
|
||||||
" \t\t groups \t all groups of the system\n" +
|
" \t\t groups \t all groups of the system\n" +
|
||||||
"Use for exporting java objects of a specified class to a xml-file.\n"
|
"Use for exporting java objects of a specified class to a xml-file.\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.portation.modules.core.categorization;
|
package com.arsdigita.portation.modules.core.categorization;
|
||||||
|
|
||||||
import com.arsdigita.kernel.ACSObject;
|
|
||||||
import com.arsdigita.portation.AbstractMarshaller;
|
import com.arsdigita.portation.AbstractMarshaller;
|
||||||
import com.arsdigita.portation.Identifiable;
|
import com.arsdigita.portation.Identifiable;
|
||||||
|
import com.arsdigita.portation.conversion.NgCollection;
|
||||||
import com.arsdigita.portation.modules.core.core.CcmObject;
|
import com.arsdigita.portation.modules.core.core.CcmObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,7 +41,17 @@ public class Categorization implements Identifiable {
|
||||||
private long objectOrder;
|
private long objectOrder;
|
||||||
|
|
||||||
|
|
||||||
public Categorization(final ACSObject acsObject) {
|
public Categorization(Category category, CcmObject categorizedObject) {
|
||||||
|
this.categorizationId = NgCollection.categorizations.size() + 1;
|
||||||
|
|
||||||
|
this.category = category;
|
||||||
|
this.categorizedObject = categorizedObject;
|
||||||
|
|
||||||
|
this.index = false;
|
||||||
|
this.categoryOrder = categorizedObject.getCategories().size() + 1;
|
||||||
|
this.objectOrder = category.getObjects().size() + 1;
|
||||||
|
|
||||||
|
NgCollection.categorizations.put(this.categorizationId, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.portation.modules.core.categorization;
|
package com.arsdigita.portation.modules.core.categorization;
|
||||||
|
|
||||||
|
import com.arsdigita.categorization.CategoryLocalization;
|
||||||
import com.arsdigita.portation.AbstractMarshaller;
|
import com.arsdigita.portation.AbstractMarshaller;
|
||||||
import com.arsdigita.portation.Identifiable;
|
import com.arsdigita.portation.Identifiable;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The category entity represents a single category. Each category is part of a
|
* The category entity represents a single category. Each category is part of a
|
||||||
|
|
@ -50,14 +54,37 @@ public class Category extends CcmObject {
|
||||||
private boolean abstractCategory;
|
private boolean abstractCategory;
|
||||||
|
|
||||||
private List<Categorization> objects;
|
private List<Categorization> objects;
|
||||||
|
|
||||||
private List<Category> subCategories;
|
private List<Category> subCategories;
|
||||||
|
|
||||||
private Category parentCategory;
|
private Category parentCategory;
|
||||||
private long categoryOrder;
|
private long categoryOrder;
|
||||||
|
|
||||||
|
|
||||||
public Category(final com.arsdigita.categorization.Category trunkCategory) {
|
public Category(final com.arsdigita.categorization.Category trunkCategory) {
|
||||||
super(trunkCategory);
|
super(trunkCategory);
|
||||||
|
|
||||||
|
this.uniqueId = trunkCategory.getID().toString();
|
||||||
|
this.name = trunkCategory.getName();
|
||||||
|
|
||||||
|
CategoryLocalization categoryLocalization = trunkCategory
|
||||||
|
.getCategoryLocalizationCollection().getCategoryLocalization();
|
||||||
|
Locale locale = new Locale(categoryLocalization.getLocale());
|
||||||
|
this.title.addValue(locale, categoryLocalization.getName());
|
||||||
|
this.description.addValue(locale, categoryLocalization.getDescription());
|
||||||
|
|
||||||
|
this.enabled = trunkCategory.isEnabled();
|
||||||
|
this.visible = trunkCategory.isVisible();
|
||||||
|
this.abstractCategory = trunkCategory.isAbstract();
|
||||||
|
|
||||||
|
this.objects = new ArrayList<>();
|
||||||
|
this.subCategories = new ArrayList<>();
|
||||||
|
|
||||||
|
//this.parentCategory
|
||||||
|
|
||||||
|
this.categoryOrder = trunkCategory.getDefaultParentCategory()
|
||||||
|
.getNumberOfChildCategories() + 1;
|
||||||
|
|
||||||
|
NgCollection.categories.put(this.getObjectId(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -70,7 +97,7 @@ public class Category extends CcmObject {
|
||||||
return uniqueId;
|
return uniqueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUniqueId(String uniqueId) {
|
public void setUniqueId(final String uniqueId) {
|
||||||
this.uniqueId = uniqueId;
|
this.uniqueId = uniqueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +105,7 @@ public class Category extends CcmObject {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(final String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +113,7 @@ public class Category extends CcmObject {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(LocalizedString title) {
|
public void setTitle(final LocalizedString title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +121,7 @@ public class Category extends CcmObject {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(LocalizedString description) {
|
public void setDescription(final LocalizedString description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +129,7 @@ public class Category extends CcmObject {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(final boolean enabled) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +137,7 @@ public class Category extends CcmObject {
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(final boolean visible) {
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +145,7 @@ public class Category extends CcmObject {
|
||||||
return abstractCategory;
|
return abstractCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbstractCategory(boolean abstractCategory) {
|
public void setAbstractCategory(final boolean abstractCategory) {
|
||||||
this.abstractCategory = abstractCategory;
|
this.abstractCategory = abstractCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,23 +153,39 @@ public class Category extends CcmObject {
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setObjects(List<Categorization> objects) {
|
public void setObjects(final List<Categorization> objects) {
|
||||||
this.objects = objects;
|
this.objects = objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addObject(final Categorization object) {
|
||||||
|
this.objects.add(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeObject(final Categorization object) {
|
||||||
|
this.objects.remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Category> getSubCategories() {
|
public List<Category> getSubCategories() {
|
||||||
return subCategories;
|
return subCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubCategories(List<Category> subCategories) {
|
public void setSubCategories(final List<Category> subCategories) {
|
||||||
this.subCategories = subCategories;
|
this.subCategories = subCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSubCategory(final Category subCategory) {
|
||||||
|
this.subCategories.add(subCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSubCategory(final Category subCategory) {
|
||||||
|
this.subCategories.remove(subCategory);
|
||||||
|
}
|
||||||
|
|
||||||
public Category getParentCategory() {
|
public Category getParentCategory() {
|
||||||
return parentCategory;
|
return parentCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentCategory(Category parentCategory) {
|
public void setParentCategory(final Category parentCategory) {
|
||||||
this.parentCategory = parentCategory;
|
this.parentCategory = parentCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +193,7 @@ public class Category extends CcmObject {
|
||||||
return categoryOrder;
|
return categoryOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategoryOrder(long categoryOrder) {
|
public void setCategoryOrder(final long categoryOrder) {
|
||||||
this.categoryOrder = categoryOrder;
|
this.categoryOrder = categoryOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,81 +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.categorization.utils;
|
|
||||||
|
|
||||||
import com.arsdigita.categorization.CategorizedCollection;
|
|
||||||
import com.arsdigita.categorization.CategoryCollection;
|
|
||||||
import com.arsdigita.portation.modules.core.categorization.Categorization;
|
|
||||||
import com.arsdigita.portation.modules.core.categorization.Category;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
|
||||||
* @version created the 6/22/16
|
|
||||||
*/
|
|
||||||
public class CollectionConverter {
|
|
||||||
|
|
||||||
public static final Logger logger = Logger.getLogger(CollectionConverter.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts CategorizationCollection of Trunk into a list of
|
|
||||||
* Categorizations of CCM_NG.
|
|
||||||
*
|
|
||||||
* @param categorizedCollection
|
|
||||||
* @param category
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<Categorization> convertCategorizations
|
|
||||||
(CategorizedCollection categorizedCollection, Category category) {
|
|
||||||
List<Categorization> categorizations = new ArrayList<>();
|
|
||||||
if (categorizedCollection != null) {
|
|
||||||
while (categorizedCollection.next()) {
|
|
||||||
//categorizations.add();
|
|
||||||
}
|
|
||||||
categorizedCollection.close();
|
|
||||||
} else {
|
|
||||||
logger.error("Failed to convertCategories, cause " +
|
|
||||||
"categoryCollection is null.");
|
|
||||||
}
|
|
||||||
return categorizations;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts CategoryCollection of Trunk into list of Categories of CCM_NG.
|
|
||||||
*
|
|
||||||
* @param categoryCollection
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<Category> convertCategories(CategoryCollection
|
|
||||||
categoryCollection) {
|
|
||||||
List<Category> categories = new ArrayList<>();
|
|
||||||
if (categoryCollection != null) {
|
|
||||||
while (categoryCollection.next()) {
|
|
||||||
//.add(new Category());
|
|
||||||
}
|
|
||||||
categoryCollection.close();
|
|
||||||
} else {
|
|
||||||
logger.error("Failed to convertCategories, cause " +
|
|
||||||
"categoryCollection is null.");
|
|
||||||
}
|
|
||||||
return categories;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -25,7 +25,9 @@ import com.arsdigita.portation.modules.core.categorization.Categorization;
|
||||||
import com.arsdigita.portation.modules.core.categorization.Category;
|
import com.arsdigita.portation.modules.core.categorization.Category;
|
||||||
import com.arsdigita.portation.modules.core.security.Permission;
|
import com.arsdigita.portation.modules.core.security.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root class of all entities in LibreCCM which need categorisation and
|
* Root class of all entities in LibreCCM which need categorisation and
|
||||||
|
|
@ -54,7 +56,13 @@ public class CcmObject implements Identifiable {
|
||||||
|
|
||||||
|
|
||||||
public CcmObject(final ACSObject trunkObject) {
|
public CcmObject(final ACSObject trunkObject) {
|
||||||
|
this.objectId = trunkObject.getID().longValue();
|
||||||
|
this.uuid = UUID.randomUUID().toString();
|
||||||
|
this.displayName = trunkObject.getDisplayName();
|
||||||
|
this.permissions = new ArrayList<>();
|
||||||
|
this.categories = new ArrayList<>();
|
||||||
|
|
||||||
|
//NgCollection.ccmObjects.put(this.objectId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -66,7 +74,7 @@ public class CcmObject implements Identifiable {
|
||||||
return objectId;
|
return objectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setObjectId(long objectId) {
|
public void setObjectId(final long objectId) {
|
||||||
this.objectId = objectId;
|
this.objectId = objectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +82,7 @@ public class CcmObject implements Identifiable {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUuid(String uuid) {
|
public void setUuid(final String uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +90,7 @@ public class CcmObject implements Identifiable {
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplayName(String displayName) {
|
public void setDisplayName(final String displayName) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,15 +98,31 @@ public class CcmObject implements Identifiable {
|
||||||
return permissions;
|
return permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPermissions(List<Permission> permissions) {
|
public void setPermissions(final List<Permission> permissions) {
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPermission(final Permission permission) {
|
||||||
|
permissions.add(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePermission(final Permission permission) {
|
||||||
|
permissions.remove(permission);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Categorization> getCategories() {
|
public List<Categorization> getCategories() {
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategories(List<Categorization> categories) {
|
public void setCategories(final List<Categorization> categories) {
|
||||||
this.categories = categories;
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCategory(final Categorization category) {
|
||||||
|
categories.add(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCategory(final Categorization category) {
|
||||||
|
categories.remove(category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,13 @@ 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.Identifiable;
|
||||||
|
import com.arsdigita.portation.conversion.NgCollection;
|
||||||
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
|
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
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>
|
||||||
|
|
@ -33,15 +37,35 @@ public class Task implements Identifiable {
|
||||||
private long taskId;
|
private long taskId;
|
||||||
private LocalizedString label;
|
private LocalizedString label;
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private String taskState;
|
private String taskState;
|
||||||
|
|
||||||
private Workflow workflow;
|
private Workflow workflow;
|
||||||
|
|
||||||
private List<Task> dependentTasks;
|
private List<Task> dependentTasks;
|
||||||
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) {
|
||||||
|
this.taskId = trunkTask.getID().longValue();
|
||||||
|
label.addValue(Locale.ENGLISH, trunkTask.getLabel());
|
||||||
|
description.addValue(Locale.ENGLISH, trunkTask.getDescription());
|
||||||
|
|
||||||
|
this.active = trunkTask.isActive();
|
||||||
|
this.taskState = trunkTask.getStateString();
|
||||||
|
|
||||||
|
//this.workflow
|
||||||
|
|
||||||
|
this.dependentTasks = new ArrayList<>();
|
||||||
|
this.dependsOn = new ArrayList<>();
|
||||||
|
this.comments = new ArrayList<>();
|
||||||
|
Iterator commentsIt = trunkTask.getComments();
|
||||||
|
while (commentsIt.hasNext()) {
|
||||||
|
addComment(commentsIt.next().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
NgCollection.tasks.put(this.getTaskId(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -53,7 +77,7 @@ public class Task implements Identifiable {
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaskId(long taskId) {
|
public void setTaskId(final long taskId) {
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +85,7 @@ public class Task implements Identifiable {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(LocalizedString label) {
|
public void setLabel(final LocalizedString label) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +93,7 @@ public class Task implements Identifiable {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(LocalizedString description) {
|
public void setDescription(final LocalizedString description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +101,7 @@ public class Task implements Identifiable {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
public void setActive(final boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +109,7 @@ public class Task implements Identifiable {
|
||||||
return taskState;
|
return taskState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaskState(String taskState) {
|
public void setTaskState(final String taskState) {
|
||||||
this.taskState = taskState;
|
this.taskState = taskState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +117,7 @@ public class Task implements Identifiable {
|
||||||
return workflow;
|
return workflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorkflow(Workflow workflow) {
|
public void setWorkflow(final Workflow workflow) {
|
||||||
this.workflow = workflow;
|
this.workflow = workflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,23 +125,48 @@ public class Task implements Identifiable {
|
||||||
return dependentTasks;
|
return dependentTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDependentTasks(List<Task> dependentTasks) {
|
public void setDependentTasks(final List<Task> dependentTasks) {
|
||||||
this.dependentTasks = dependentTasks;
|
this.dependentTasks = dependentTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addDependentTask(final Task task) {
|
||||||
|
dependentTasks.add(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDependentTask(final Task task) {
|
||||||
|
dependentTasks.remove(task);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Task> getDependsOn() {
|
public List<Task> getDependsOn() {
|
||||||
return dependsOn;
|
return dependsOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDependsOn(List<Task> dependsOn) {
|
public void setDependsOn(final List<Task> dependsOn) {
|
||||||
this.dependsOn = dependsOn;
|
this.dependsOn = dependsOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addDependsOn(final Task task) {
|
||||||
|
dependsOn.add(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeDependsOn(final Task task) {
|
||||||
|
dependsOn.remove(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> getComments() {
|
public List<String> getComments() {
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setComments(List<String> comments) {
|
public void setComments(final List<String> comments) {
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addComment(final String comment) {
|
||||||
|
comments.add(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeComment(final String comment) {
|
||||||
|
comments.remove(comment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,12 @@ 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.Identifiable;
|
||||||
|
import com.arsdigita.portation.conversion.NgCollection;
|
||||||
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
|
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
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>
|
||||||
|
|
@ -35,9 +38,13 @@ public class Workflow implements Identifiable {
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
private List<Task> tasks;
|
private List<Task> tasks;
|
||||||
|
|
||||||
public Workflow(final com.arsdigita.workflow.simple.Workflow
|
public Workflow(final com.arsdigita.workflow.simple.Workflow trunkWorkFlow) {
|
||||||
trunkWorkFlow) {
|
this.workflowId = trunkWorkFlow.getID().longValue();
|
||||||
|
this.name.addValue(Locale.ENGLISH, trunkWorkFlow.getDisplayName());
|
||||||
|
this.description.addValue(Locale.ENGLISH, trunkWorkFlow.getDescription());
|
||||||
|
this.tasks = new ArrayList<>();
|
||||||
|
|
||||||
|
NgCollection.workflows.put(this.workflowId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -49,7 +56,7 @@ public class Workflow implements Identifiable {
|
||||||
return workflowId;
|
return workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorkflowId(long workflowId) {
|
public void setWorkflowId(final long workflowId) {
|
||||||
this.workflowId = workflowId;
|
this.workflowId = workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +64,7 @@ public class Workflow implements Identifiable {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(LocalizedString name) {
|
public void setName(final LocalizedString name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +72,7 @@ public class Workflow implements Identifiable {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(LocalizedString description) {
|
public void setDescription(final LocalizedString description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +80,15 @@ public class Workflow implements Identifiable {
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTasks(List<Task> tasks) {
|
public void setTasks(final List<Task> tasks) {
|
||||||
this.tasks = tasks;
|
this.tasks = tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addTask(final Task task) {
|
||||||
|
tasks.add(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTask(final Task task) {
|
||||||
|
tasks.remove(task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,95 +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.utils;
|
|
||||||
|
|
||||||
import com.arsdigita.kernel.EmailAddress;
|
|
||||||
import com.arsdigita.kernel.GroupCollection;
|
|
||||||
import com.arsdigita.kernel.PartyCollection;
|
|
||||||
import com.arsdigita.kernel.UserCollection;
|
|
||||||
import com.arsdigita.portation.modules.core.security.Group;
|
|
||||||
import com.arsdigita.portation.modules.core.security.Party;
|
|
||||||
import com.arsdigita.portation.modules.core.security.User;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
|
||||||
* @version created the 01.06.16
|
|
||||||
*/
|
|
||||||
public class CollectionConverter {
|
|
||||||
private static final Logger logger = Logger.getLogger(CollectionConverter.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<Party> convertParties(PartyCollection partyCollection) {
|
|
||||||
List<Party> parties = new ArrayList<>();
|
|
||||||
if (partyCollection != null) {
|
|
||||||
while (partyCollection.next()) {
|
|
||||||
parties.add(new Party());
|
|
||||||
}
|
|
||||||
partyCollection.close();
|
|
||||||
} else {
|
|
||||||
logger.error("A Failed to exportUsers, cause party collection is null.");
|
|
||||||
}
|
|
||||||
return parties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<User> convertUsers(UserCollection userCollection) {
|
|
||||||
List<User> users = new ArrayList<>();
|
|
||||||
if (userCollection != null) {
|
|
||||||
while (userCollection.next()) {
|
|
||||||
users.add(new User());
|
|
||||||
}
|
|
||||||
userCollection.close();
|
|
||||||
} else {
|
|
||||||
logger.error("A Failed to exportUsers, cause user collection is null.");
|
|
||||||
}
|
|
||||||
return users;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Group> convertGroups(GroupCollection groupCollection) {
|
|
||||||
List<Group> groups = new ArrayList<>();
|
|
||||||
if (groupCollection != null) {
|
|
||||||
while (groupCollection.next()) {
|
|
||||||
groups.add(new Group());
|
|
||||||
}
|
|
||||||
groupCollection.close();
|
|
||||||
} else {
|
|
||||||
logger.error("A Failed to exportUsers, cause group collection is null.");
|
|
||||||
}
|
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> convertMailAddresses(Iterator it) {
|
|
||||||
List<String> mailAddresses = new ArrayList<>();
|
|
||||||
if (it != null) {
|
|
||||||
while (it.hasNext()) {
|
|
||||||
mailAddresses.add(((EmailAddress) it.next()).getEmailAddress());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.error("A Failed to exportUsers, cause mail collection is null.");
|
|
||||||
}
|
|
||||||
return mailAddresses;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -34,14 +34,17 @@ import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.persistence.metadata.ObjectType;
|
import com.arsdigita.persistence.metadata.ObjectType;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a process instance that is assigned to a particular process that
|
* Represents a process instance that is assigned to a particular process that
|
||||||
|
|
@ -856,4 +859,23 @@ public class Workflow extends Task {
|
||||||
public static Workflow getObjectWorkflow(ACSObject o) {
|
public static Workflow getObjectWorkflow(ACSObject o) {
|
||||||
return getObjectWorkflow(o.getID());
|
return getObjectWorkflow(o.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Workflow> getObjectWorkflows() {
|
||||||
|
List<Workflow> workflowList = new ArrayList<>();
|
||||||
|
|
||||||
|
final Session session = SessionManager.getSession();
|
||||||
|
final DataQuery query = session.retrieveQuery("com.arsdigita.workflow.simple.getProcesses");
|
||||||
|
|
||||||
|
BigDecimal workflowID = null;
|
||||||
|
while (query.next()) {
|
||||||
|
workflowID = (BigDecimal) query.get("processID");
|
||||||
|
|
||||||
|
if (workflowID != null) {
|
||||||
|
workflowList.add(new Workflow(workflowID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query.close();
|
||||||
|
return workflowList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue