From 9f315acff67d15be952340c64cc6021f0bb1689c Mon Sep 17 00:00:00 2001 From: N Smith Date: Tue, 3 Aug 2010 11:41:28 +0000 Subject: [PATCH] Updated the Workflow Rest API classes to use the getter methods on various Workflow DTOs instead of accessing the public fields. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21565 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../java/org/alfresco/repo/forms/Field.java | 3 +- .../processor/FilteredFormProcessor.java | 2 +- .../forms/processor/FormCreationData.java | 34 +------- .../processor/FormCreationData.java.svntmp | 48 +++++++++++ .../forms/processor/FormCreationDataImpl.java | 83 +++++++++++++++++++ .../processor/node/FieldProcessorTest.java | 3 +- .../processor/workflow/TaskFormPersister.java | 2 +- .../workflow/TypedPropertyValueGetter.java | 2 +- .../workflow/WorkflowFormProcessor.java | 2 +- 9 files changed, 143 insertions(+), 36 deletions(-) create mode 100644 source/java/org/alfresco/repo/forms/processor/FormCreationData.java.svntmp create mode 100644 source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java diff --git a/source/java/org/alfresco/repo/forms/Field.java b/source/java/org/alfresco/repo/forms/Field.java index 8fba2dc124..eac460bc29 100644 --- a/source/java/org/alfresco/repo/forms/Field.java +++ b/source/java/org/alfresco/repo/forms/Field.java @@ -20,8 +20,9 @@ package org.alfresco.repo.forms; /** - * Interface definition of a field + * Interface defining a field in a {@link Form}. * + * @since 3.4 * @author Nick Smith */ public interface Field diff --git a/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java index 628aeeb4ba..b1ce2ff15a 100644 --- a/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java @@ -165,7 +165,7 @@ public abstract class FilteredFormProcessor extends Abstr formItem.setUrl(getItemURI(item)); Object itemData = makeItemData(item); - FormCreationData data = new FormCreationData(itemData, forcedFields, context); + FormCreationData data = new FormCreationDataImpl(itemData, forcedFields, context); populateForm(form, fields, data); if (log.isDebugEnabled()) // log.debug("Generated form: " + form); diff --git a/source/java/org/alfresco/repo/forms/processor/FormCreationData.java b/source/java/org/alfresco/repo/forms/processor/FormCreationData.java index c1be995831..b4ea379b8a 100644 --- a/source/java/org/alfresco/repo/forms/processor/FormCreationData.java +++ b/source/java/org/alfresco/repo/forms/processor/FormCreationData.java @@ -25,7 +25,6 @@ package org.alfresco.repo.forms.processor; -import java.util.List; import java.util.Map; /** @@ -33,46 +32,21 @@ import java.util.Map; * @since 3.4 * @author Nick Smith */ -public class FormCreationData +public interface FormCreationData { - private final Object itemData; - private final List forcedFields; - private final Map context; - - public FormCreationData(Object itemData, - List forcedFields, - Map context) - { - this.itemData = itemData; - this.forcedFields = forcedFields; - this.context = context; - } - - /** * @return the itemData */ - public Object getItemData() - { - return itemData; - } + Object getItemData(); /** * @return If the fieldName given is a forced field then * returns true, otherwise returns false. */ - public boolean isForcedField(String fieldName) - { - if (forcedFields == null) - return false; - return forcedFields.contains(fieldName); - } + boolean isForcedField(String fieldName); /** * @return the context */ - public Map getContext() - { - return context; - } + Map getContext(); } diff --git a/source/java/org/alfresco/repo/forms/processor/FormCreationData.java.svntmp b/source/java/org/alfresco/repo/forms/processor/FormCreationData.java.svntmp new file mode 100644 index 0000000000..f6a819adc6 --- /dev/null +++ b/source/java/org/alfresco/repo/forms/processor/FormCreationData.java.svntmp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco 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 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Alfresco. If not, see . + */ + +package org.alfresco.repo.forms.processor; + +import java.util.Map; + +/** + * @since 3.4 + * @author Nick Smith + * + */ +public interface FormCreationData +{ + + /** + * @return the itemData + */ + public abstract Object getItemData(); + + /** + * @return If the fieldName given is a forced field then + * returns true, otherwise returns false. + */ + public abstract boolean isForcedField(String fieldName); + + /** + * @return the context + */ + public abstract Map getContext(); + +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java b/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java new file mode 100644 index 0000000000..3ddac4da8b --- /dev/null +++ b/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ + +package org.alfresco.repo.forms.processor; + +import java.util.List; +import java.util.Map; + +/** + * Simple DTO containing various objects needed to generate Forms. + * + * @since 3.4 + * @author Nick Smith + */ +public class FormCreationDataImpl implements FormCreationData +{ + private final Object itemData; + private final List forcedFields; + private final Map context; + + public FormCreationDataImpl(Object itemData, List forcedFields, Map context) + { + this.itemData = itemData; + this.forcedFields = forcedFields; + this.context = context; + } + + /* + * (non-Javadoc) + * + * @see org.alfresco.repo.forms.processor.FormCreationData#getItemData() + */ + public Object getItemData() + { + return itemData; + } + + /* + * (non-Javadoc) + * + * @see + * org.alfresco.repo.forms.processor.FormCreationData#isForcedField(java + * .lang.String) + */ + public boolean isForcedField(String fieldName) + { + if (forcedFields == null) + return false; + return forcedFields.contains(fieldName); + } + + /* + * (non-Javadoc) + * + * @see org.alfresco.repo.forms.processor.FormCreationData#getContext() + */ + public Map getContext() + { + return context; + } +} diff --git a/source/java/org/alfresco/repo/forms/processor/node/FieldProcessorTest.java b/source/java/org/alfresco/repo/forms/processor/node/FieldProcessorTest.java index 1474e0e723..7157a1b8b7 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/FieldProcessorTest.java +++ b/source/java/org/alfresco/repo/forms/processor/node/FieldProcessorTest.java @@ -33,6 +33,7 @@ import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.PropertyFieldDefinition; import org.alfresco.repo.forms.AssociationFieldDefinition.Direction; import org.alfresco.repo.forms.processor.FormCreationData; +import org.alfresco.repo.forms.processor.FormCreationDataImpl; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.namespace.NamespaceService; @@ -132,7 +133,7 @@ public class FieldProcessorTest extends TestCase { super.setUp(); namespaceService = makeNamespaceService(); - data = new FormCreationData(makeItemData(), null, null); + data = new FormCreationDataImpl(makeItemData(), null, null); } private ItemData makeItemData() diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormPersister.java b/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormPersister.java index ee9ff7aab4..2356ccc83b 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormPersister.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/TaskFormPersister.java @@ -144,7 +144,7 @@ public class TaskFormPersister extends ContentModelFormPersister { return updater.update(); } - else if(transitionId.isEmpty()) + else if(transitionId.length()==0) { return updater.transition(); } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java b/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java index bfc8464228..acb331c226 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java @@ -74,7 +74,7 @@ public class TypedPropertyValueGetter // make sure empty strings stay as empty strings, everything else // should be represented as null - if(valStr.isEmpty() && !isTextProperty(propDef)) + if(valStr.length()==0 && !isTextProperty(propDef)) { // Do nothing, leave typedValue as null. } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java index 97b48eba3e..23cd22119c 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java @@ -32,7 +32,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * Temporary FormProcessor implementation that can generate and persist + * FormProcessor implementation that can generate and persist * Form objects for workflow definitions. * *@since 3.4