mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
Initial checkin for foundations of repo FormService and FormUI Share component. Test page also added to Share which just contains the new FormUI component: http://localhost:8081/share/page/form-test
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12179 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
3bd69a1734
commit
d3e0477d38
@ -47,6 +47,7 @@
|
||||
<import resource="classpath:alfresco/swf-transform-context.xml"/>
|
||||
<import resource="classpath:alfresco/site-services-context.xml"/>
|
||||
<import resource="classpath:alfresco/tagging-services-context.xml"/>
|
||||
<import resource="classpath:alfresco/form-services-context.xml"/>
|
||||
<import resource="classpath:alfresco/cmis-api-context.xml" />
|
||||
<import resource="classpath*:alfresco/patch/*-context.xml" />
|
||||
<import resource="classpath*:alfresco/domain/*-context.xml" />
|
||||
|
43
config/alfresco/form-services-context.xml
Normal file
43
config/alfresco/form-services-context.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<!-- form service bean -->
|
||||
<bean id="FormService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.repo.forms.FormService</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="formService"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="AuditMethodInterceptor"/>
|
||||
<idref bean="exceptionTranslator"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="formService" class="org.alfresco.repo.forms.FormServiceImpl">
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="fileFolderService" ref="FileFolderService"/>
|
||||
<property name="searchService" ref="SearchService"/>
|
||||
<property name="permissionService" ref="PermissionService" />
|
||||
</bean>
|
||||
|
||||
<!-- Form model processor factory bean -->
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<bean id="formServiceScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.forms.script.ScriptFormService">
|
||||
<property name="extensionName">
|
||||
<value>formService</value>
|
||||
</property>
|
||||
<property name="serviceRegistry" ref="ServiceRegistry"/>
|
||||
<property name="formService" ref="formService"/>
|
||||
</bean>
|
||||
-->
|
||||
|
||||
</beans>
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
/**
|
||||
* An association field definition.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class AssociationFieldDefiniton extends FieldDefinition
|
||||
{
|
||||
//
|
||||
// TODO: Think about bi-directional association support,
|
||||
// should we instead model as endpointType etc.
|
||||
// and have a 'direction' flag, that would then allow
|
||||
// form clients to display source objects not just
|
||||
// target objects
|
||||
//
|
||||
|
||||
protected String targetType;
|
||||
protected String targetRole;
|
||||
protected boolean targetMandatory;
|
||||
protected boolean targetMany;
|
||||
|
||||
// TODO: This may not even be needed for forms, what difference does it make!?
|
||||
protected boolean childAssociation;
|
||||
|
||||
/**
|
||||
* Constructs an AssociationFieldDefinition
|
||||
*
|
||||
* @param name The name of the property
|
||||
* @param label The display label of the property
|
||||
* @param description The description of the property
|
||||
* @param dataType The data type of the property
|
||||
* @param defaultValue Default value of the property
|
||||
* @param binding Binding of the property
|
||||
* @param protectedField Whether the property should be read only
|
||||
* @param mandatory Whether the property is mandatory
|
||||
* @param repeats Whether the property can contain multiple values
|
||||
* @param group The group the property belongs to
|
||||
* @param targetMandatory Whether a target is mandatory
|
||||
* @param targetMany Whether there can be multiple targets
|
||||
* @param targetType The type of the target
|
||||
* @param childAssociation Whether the association is a child association
|
||||
*/
|
||||
// TODO: Look at the Builder pattern to reduce the size of the constructor!!
|
||||
public AssociationFieldDefiniton(String name, String label, String description,
|
||||
String defaultValue, String binding, boolean protectedField,
|
||||
FieldGroup group, boolean targetMandatory, boolean targetMany,
|
||||
String targetRole, String targetType, boolean childAssociation)
|
||||
{
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
this.defaultValue = defaultValue;
|
||||
this.binding = binding;
|
||||
this.protectedField = protectedField;
|
||||
this.group = group;
|
||||
|
||||
this.targetMandatory = targetMandatory;
|
||||
this.targetMany = targetMany;
|
||||
this.targetType = targetType;
|
||||
|
||||
this.childAssociation = childAssociation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the target of the association
|
||||
*
|
||||
* @return The type of the target
|
||||
*/
|
||||
public String getTargetType()
|
||||
{
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the target is mandatory
|
||||
*
|
||||
* @return true if a target has to be selected
|
||||
*/
|
||||
public boolean isTargetMandatory()
|
||||
{
|
||||
return this.targetMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if multiple targets can be selected
|
||||
*
|
||||
* @return true if multiple targets can be selected
|
||||
*/
|
||||
public boolean isTargetMany()
|
||||
{
|
||||
return this.targetMany;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the association is a child association
|
||||
*
|
||||
* @return true if the association is a child association
|
||||
*/
|
||||
public boolean isChildAssociation()
|
||||
{
|
||||
return this.childAssociation;
|
||||
}
|
||||
}
|
114
source/java/org/alfresco/repo/forms/FieldDefinition.java
Normal file
114
source/java/org/alfresco/repo/forms/FieldDefinition.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
/**
|
||||
* Abstract representation of a field defintion.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public abstract class FieldDefinition
|
||||
{
|
||||
protected String name;
|
||||
protected String label;
|
||||
protected String description;
|
||||
protected String binding;
|
||||
protected String defaultValue;
|
||||
protected FieldGroup group;
|
||||
protected boolean protectedField;
|
||||
|
||||
/**
|
||||
* Returns the name of the field
|
||||
*
|
||||
* @return The field's name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display label for the field
|
||||
*
|
||||
* @return The field's display label
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the field
|
||||
*
|
||||
* @return The field's description
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the binding for the field, this is used by some
|
||||
* FormModelProcessor implementations to generate an
|
||||
* alternative representation of the data
|
||||
*
|
||||
* @return The field's binding
|
||||
*/
|
||||
public String getBinding()
|
||||
{
|
||||
return this.binding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns any default value the field may have
|
||||
*
|
||||
* @return The field's default value or null if there isn't one
|
||||
*/
|
||||
public String getDefaultValue()
|
||||
{
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the group the field may be a part of
|
||||
*
|
||||
* @return The field's group or null if it does not belong to a group
|
||||
*/
|
||||
public FieldGroup getGroup()
|
||||
{
|
||||
return this.group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the field is protected i.e. it should be rendered
|
||||
* as read-only in any client displaying the field
|
||||
*
|
||||
* @return true if the field is protected
|
||||
*/
|
||||
public boolean isProtectedField()
|
||||
{
|
||||
return this.protectedField;
|
||||
}
|
||||
}
|
110
source/java/org/alfresco/repo/forms/FieldGroup.java
Normal file
110
source/java/org/alfresco/repo/forms/FieldGroup.java
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
/**
|
||||
* Represents a field group
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class FieldGroup
|
||||
{
|
||||
protected String id;
|
||||
protected String label;
|
||||
protected FieldGroup parent;
|
||||
protected boolean repeats;
|
||||
protected boolean mandatory;
|
||||
|
||||
/**
|
||||
* Constructs a FieldGroup
|
||||
*
|
||||
* @param id The id of the group
|
||||
* @param label The display label of the group
|
||||
* @param mandatory Whether the group is mandatory
|
||||
* @param repeats Whether the group of fields can repeat
|
||||
* @param parent The group's parent group or null if it
|
||||
* doesn't have a parent
|
||||
*/
|
||||
public FieldGroup(String id, String label, boolean mandatory,
|
||||
boolean repeats, FieldGroup parent)
|
||||
{
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
this.mandatory = mandatory;
|
||||
this.parent = parent;
|
||||
this.repeats = repeats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the group
|
||||
*
|
||||
* @return The id of the group
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display label of the group
|
||||
*
|
||||
* @return The display label of the group
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent group
|
||||
*
|
||||
* @return The parent group or null if there isn't a parent
|
||||
*/
|
||||
public FieldGroup getParent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the fields inside this group can
|
||||
* repeat multiple times
|
||||
*
|
||||
* @return true if the group repeats
|
||||
*/
|
||||
public boolean isRepeating()
|
||||
{
|
||||
return this.repeats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the group is mandatory
|
||||
*
|
||||
* @return true if the group is mandatory
|
||||
*/
|
||||
public boolean isMandatory()
|
||||
{
|
||||
return this.mandatory;
|
||||
}
|
||||
}
|
134
source/java/org/alfresco/repo/forms/Form.java
Normal file
134
source/java/org/alfresco/repo/forms/Form.java
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Data representation of a form to be displayed in the UI.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class Form
|
||||
{
|
||||
protected String item;
|
||||
protected String submissionUrl;
|
||||
protected String type;
|
||||
protected List<FieldDefinition> fieldDefinitions;
|
||||
protected List<FieldGroup> fieldGroups;
|
||||
protected Map<String, String> formData;
|
||||
|
||||
/**
|
||||
* Constructs a Form
|
||||
*
|
||||
* @param item The identifier
|
||||
* @param submissionUrl Default submission URL
|
||||
* @param type The type of the item
|
||||
* @param fieldDefinitions List of fields that could be displayed
|
||||
* @param fieldGroups List of field groups
|
||||
* @param formData Map of the form data
|
||||
*/
|
||||
public Form(String item, String submissionUrl, String type,
|
||||
List<FieldDefinition> fieldDefinitions, List<FieldGroup> fieldGroups,
|
||||
Map<String, String> formData)
|
||||
{
|
||||
this.fieldDefinitions = fieldDefinitions;
|
||||
this.fieldGroups = fieldGroups;
|
||||
this.formData = formData;
|
||||
this.item = item;
|
||||
this.submissionUrl = submissionUrl;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an identifier for the item the form is for, in the case of a node
|
||||
* it will be a NodeRef, for a task, a task id etc.
|
||||
*
|
||||
* @return The item
|
||||
*/
|
||||
public String getItem()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the submission URL to use to post back to this service, acts as a
|
||||
* default URL for clients to use
|
||||
*
|
||||
* @return The default submission URL
|
||||
*/
|
||||
public String getSubmissionUrl()
|
||||
{
|
||||
return this.submissionUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the item the form is for, could be a content model type, a
|
||||
* workflow task type, an XML schema etc.
|
||||
*
|
||||
* @return The type of the item
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields appropriate for the item
|
||||
*
|
||||
* @return List of FieldDefintion objects or null if there are no fields
|
||||
*/
|
||||
public List<FieldDefinition> getFieldDefinitions()
|
||||
{
|
||||
return this.fieldDefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of field groups for the form
|
||||
*
|
||||
* @return List of FieldGroup objects or null if there are no groups
|
||||
*/
|
||||
public List<FieldGroup> getFieldGroups()
|
||||
{
|
||||
return this.fieldGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data to display in the form
|
||||
*
|
||||
* @return Map of String objects representing the form data or null if
|
||||
* there is no data
|
||||
*/
|
||||
public Map<String, String> getFormData()
|
||||
{
|
||||
return this.formData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
52
source/java/org/alfresco/repo/forms/FormService.java
Normal file
52
source/java/org/alfresco/repo/forms/FormService.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
|
||||
/**
|
||||
* Form service fundamental API.
|
||||
* <p>
|
||||
* This service API is designed to support the public facing Form APIs
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public interface FormService
|
||||
{
|
||||
/**
|
||||
* Returns a form representation of the item with the given id
|
||||
*
|
||||
* @param id The id of the item to get a form for
|
||||
* @return The Form representation
|
||||
*/
|
||||
public Form getForm(String id);
|
||||
|
||||
/**
|
||||
* Persists the given form representation for the given id
|
||||
*
|
||||
* @param id The id of the item to persist the form for
|
||||
* @param form The Form representation
|
||||
*/
|
||||
public void saveForm(String id, Form form);
|
||||
}
|
109
source/java/org/alfresco/repo/forms/FormServiceImpl.java
Normal file
109
source/java/org/alfresco/repo/forms/FormServiceImpl.java
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Form Service Implementation.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class FormServiceImpl implements FormService
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(FormServiceImpl.class);
|
||||
|
||||
/** Services */
|
||||
private NodeService nodeService;
|
||||
private FileFolderService fileFolderService;
|
||||
private SearchService searchService;
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* Set node service
|
||||
*
|
||||
* @param nodeService node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file folder service
|
||||
*
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search service
|
||||
*
|
||||
* @param searchService search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set permission service
|
||||
*
|
||||
* @param permissionService permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.forms.FormService#getForm(java.lang.String)
|
||||
*/
|
||||
public Form getForm(String id)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Retrieving form for item with id: " + id);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.repo.forms.FormService#saveForm(java.lang.String, org.alfresco.repo.forms.Form)
|
||||
*/
|
||||
public void saveForm(String id, Form form)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Saving form for item with id '" + id + "': " + form);
|
||||
}
|
||||
}
|
62
source/java/org/alfresco/repo/forms/FormServiceImplTest.java
Normal file
62
source/java/org/alfresco/repo/forms/FormServiceImplTest.java
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
import org.alfresco.util.BaseAlfrescoSpringTest;
|
||||
|
||||
/**
|
||||
* Form service implementation unit test.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class FormServiceImplTest extends BaseAlfrescoSpringTest
|
||||
{
|
||||
private FormService formService;
|
||||
|
||||
/**
|
||||
* Called during the transaction setup
|
||||
*/
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
{
|
||||
super.onSetUpInTransaction();
|
||||
|
||||
// Get the required services
|
||||
this.formService = (FormService)this.applicationContext.getBean("FormService");
|
||||
}
|
||||
|
||||
public void testGetForm() throws Exception
|
||||
{
|
||||
Form form = this.formService.getForm("");
|
||||
assertNull(form);
|
||||
}
|
||||
|
||||
// == Test the JavaScript API ==
|
||||
|
||||
// public void testJSAPI() throws Exception
|
||||
// {
|
||||
// ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/forms/script/test_formService.js");
|
||||
// this.scriptService.executeScript(location, new HashMap<String, Object>(0));
|
||||
// }
|
||||
}
|
161
source/java/org/alfresco/repo/forms/PropertyFieldDefiniton.java
Normal file
161
source/java/org/alfresco/repo/forms/PropertyFieldDefiniton.java
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A property field definition.
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class PropertyFieldDefiniton extends FieldDefinition
|
||||
{
|
||||
protected String dataType;
|
||||
protected boolean mandatory;
|
||||
protected boolean repeats;
|
||||
protected List<FieldConstraint> constraints;
|
||||
|
||||
/**
|
||||
* Constructs a FieldDefinition
|
||||
*
|
||||
* @param name The name of the property
|
||||
* @param label The display label of the property
|
||||
* @param description The description of the property
|
||||
* @param dataType The data type of the property
|
||||
* @param defaultValue Default value of the property
|
||||
* @param binding Binding of the property
|
||||
* @param protectedField Whether the property should be read only
|
||||
* @param mandatory Whether the property is mandatory
|
||||
* @param repeats Whether the property can contain multiple values
|
||||
* @param group The group the property belongs to
|
||||
* @param constraints List of constraints the property has
|
||||
*/
|
||||
// TODO: Look at the Builder pattern to reduce the size of the constructor!!
|
||||
public PropertyFieldDefiniton(String name, String label, String description,
|
||||
String dataType, String defaultValue, String binding,
|
||||
boolean protectedField, boolean mandatory, boolean repeats,
|
||||
FieldGroup group, List<FieldConstraint> constraints)
|
||||
{
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
this.defaultValue = defaultValue;
|
||||
this.binding = binding;
|
||||
this.protectedField = protectedField;
|
||||
this.group = group;
|
||||
|
||||
this.dataType = dataType;
|
||||
this.mandatory = mandatory;
|
||||
this.repeats = repeats;
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dataType for the property, this is a value from the
|
||||
* Alfresco data dictionary i.e. d:text, d:int etc.
|
||||
*
|
||||
* @return The field's data type
|
||||
*/
|
||||
public String getDataType()
|
||||
{
|
||||
return this.dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the property is mandatory
|
||||
*
|
||||
* @return true if the field is mandatory
|
||||
*/
|
||||
public boolean isMandatory()
|
||||
{
|
||||
return this.mandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the property can contain multiple values
|
||||
*
|
||||
* @return true if the field can contain multiple values
|
||||
*/
|
||||
public boolean isRepeating()
|
||||
{
|
||||
return this.repeats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of constraints the property may have
|
||||
*
|
||||
* @return List of FieldContstraint objects or null if there are
|
||||
* no constraints for the field
|
||||
*/
|
||||
public List<FieldConstraint> getConstraints()
|
||||
{
|
||||
return this.constraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a constraint on a property field
|
||||
*/
|
||||
public class FieldConstraint
|
||||
{
|
||||
protected String name;
|
||||
protected Map<String, String> params;
|
||||
|
||||
/**
|
||||
* Constructs a FieldConstraint
|
||||
*
|
||||
* @param name The name of the constraint
|
||||
* @param params Map of parameters for the constraint
|
||||
*/
|
||||
public FieldConstraint(String name, Map<String, String> params)
|
||||
{
|
||||
super();
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the constraint
|
||||
*
|
||||
* @return The constraint name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters for the constraint
|
||||
*
|
||||
* @return Map of parameters for the constraint or null if
|
||||
* there are no parameters
|
||||
*/
|
||||
public Map<String, String> getParams()
|
||||
{
|
||||
return this.params;
|
||||
}
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ package org.alfresco.repo.service;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.mbeans.VirtServerRegistry;
|
||||
import org.alfresco.repo.forms.FormService;
|
||||
import org.alfresco.repo.site.SiteService;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
@ -458,22 +459,32 @@ public class ServiceDescriptorRegistry
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getDeploymentService()
|
||||
*/
|
||||
public DeploymentService getDeploymentService() {
|
||||
public DeploymentService getDeploymentService()
|
||||
{
|
||||
return (DeploymentService) getService(DEPLOYMENT_SERVICE);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getWebProjectService()
|
||||
*/
|
||||
public WebProjectService getWebProjectService() {
|
||||
public WebProjectService getWebProjectService()
|
||||
{
|
||||
return (WebProjectService)getService(WEBPROJECT_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getSandboxService()
|
||||
*/
|
||||
public SandboxService getSandboxService() {
|
||||
public SandboxService getSandboxService()
|
||||
{
|
||||
return (SandboxService)getService(SANDBOX_SERVICE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.ServiceRegistry#getFormService()
|
||||
*/
|
||||
public FormService getFormService()
|
||||
{
|
||||
return (FormService)getService(FORM_SERVICE);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package org.alfresco.service;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.mbeans.VirtServerRegistry;
|
||||
import org.alfresco.repo.forms.FormService;
|
||||
import org.alfresco.repo.site.SiteService;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
@ -131,6 +132,7 @@ public interface ServiceRegistry
|
||||
static final QName DEPLOYMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DeploymentService");
|
||||
static final QName WEBPROJECT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WebProjectService");
|
||||
static final QName SANDBOX_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SandboxService");
|
||||
static final QName FORM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FormService");
|
||||
|
||||
/**
|
||||
* Get the list of services provided by the Repository
|
||||
@ -438,4 +440,11 @@ public interface ServiceRegistry
|
||||
*/
|
||||
@NotAuditable
|
||||
SandboxService getSandboxService();
|
||||
|
||||
/**
|
||||
* Get the form service (or null if one is not provided)
|
||||
* @return
|
||||
*/
|
||||
@NotAuditable
|
||||
FormService getFormService();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user