mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
CMIS Relationship support in AtomPub binding
- getRelationships - getRelationship - createRelationship - unit tests for above TODO: delete relationship, includeRelationships flag git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14461 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
4980a463ee
commit
d8c87a5abd
@ -26,6 +26,7 @@ package org.alfresco.cmis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@ -51,7 +52,7 @@ public interface CMISPropertyAccessor
|
||||
public QName getMappedProperty();
|
||||
|
||||
/**
|
||||
* Get the property value
|
||||
* Get the property value for a node
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
@ -59,10 +60,18 @@ public interface CMISPropertyAccessor
|
||||
public Serializable getValue(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Set the property value
|
||||
* Set the property value for a node
|
||||
*
|
||||
* @param nodeRef
|
||||
* @Param value
|
||||
*/
|
||||
public void setValue(NodeRef nodeRef, Serializable value);
|
||||
|
||||
/**
|
||||
* Get the property value for an association
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef);
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.cmis;
|
||||
|
||||
/**
|
||||
* CMIS Types Filter Enum
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public enum CMISRelationshipDirectionEnum implements EnumLabel
|
||||
{
|
||||
SOURCE("source"),
|
||||
TARGET("target"),
|
||||
BOTH("both");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISRelationshipDirectionEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISRelationshipDirectionEnum> FACTORY = new EnumFactory<CMISRelationshipDirectionEnum>(CMISRelationshipDirectionEnum.class, BOTH);
|
||||
}
|
@ -27,6 +27,7 @@ package org.alfresco.cmis;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
@ -86,7 +87,28 @@ public interface CMISServices
|
||||
public NodeRef[] getCheckedOut(String username, NodeRef folder, boolean includeDescendants);
|
||||
|
||||
/**
|
||||
* Get a single property
|
||||
* Query for relationship
|
||||
*
|
||||
* @param relDef
|
||||
* @param source
|
||||
* @param target
|
||||
* @return relationship
|
||||
*/
|
||||
public AssociationRef getRelationship(CMISTypeDefinition relDef, NodeRef source, NodeRef target);
|
||||
|
||||
/**
|
||||
* Query for relationships
|
||||
*
|
||||
* @param item node to query relationships for
|
||||
* @param relDef type of relationship to query (or null, for all relationships)
|
||||
* @param includeSubTypes
|
||||
* @param direction limit direction of relationships to query (or null, for both directions)
|
||||
* @return relationships
|
||||
*/
|
||||
public AssociationRef[] getRelationships(NodeRef node, CMISTypeDefinition relDef, boolean includeSubTypes, CMISRelationshipDirectionEnum direction);
|
||||
|
||||
/**
|
||||
* Get a single property for a node
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param propertyName
|
||||
@ -94,6 +116,15 @@ public interface CMISServices
|
||||
*/
|
||||
public Serializable getProperty(NodeRef nodeRef, String propertyName);
|
||||
|
||||
/**
|
||||
* Get a single property for an association
|
||||
*
|
||||
* @param assocRef
|
||||
* @param propertyName
|
||||
* @return value
|
||||
*/
|
||||
public Serializable getProperty(AssociationRef assocRef, String propertyName);
|
||||
|
||||
/**
|
||||
* Get all properties
|
||||
*
|
||||
|
@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.cmis;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ public class EnumFactory<E extends Enum<E>>
|
||||
*
|
||||
* @return default enum (or null, if no default specified)
|
||||
*/
|
||||
public Enum<E> defaultEnum()
|
||||
public Enum<E> getDefaultEnum()
|
||||
{
|
||||
return defaultEnum;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class EnumFactory<E extends Enum<E>>
|
||||
*
|
||||
* @return label of default enum (or null, if no default specified)
|
||||
*/
|
||||
public String defaultLabel()
|
||||
public String getDefaultLabel()
|
||||
{
|
||||
return label(defaultEnum);
|
||||
}
|
||||
@ -150,7 +150,7 @@ public class EnumFactory<E extends Enum<E>>
|
||||
*/
|
||||
public Enum<E> toEnum(String label)
|
||||
{
|
||||
Enum<E> e = fromLabel(label);
|
||||
Enum<E> e = (label == null) ? null : fromLabel(label);
|
||||
if (e == null)
|
||||
{
|
||||
e = defaultEnum;
|
||||
|
@ -276,6 +276,10 @@ public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBea
|
||||
else
|
||||
{
|
||||
typeDef = getRegistry().typeDefsByQName.get(clazz);
|
||||
if (typeDef == null)
|
||||
{
|
||||
typeDef = getRegistry().assocDefsByQName.get(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure matches one of provided matching scopes
|
||||
|
@ -450,4 +450,30 @@ public class CMISAbstractTypeDefinition implements CMISTypeDefinition, Serializa
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return objectTypeId.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final CMISTypeDefinition other = (CMISTypeDefinition) obj;
|
||||
if (objectTypeId == null)
|
||||
{
|
||||
if (other.getTypeId() != null)
|
||||
return false;
|
||||
}
|
||||
else if (!objectTypeId.equals(other.getTypeId()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,13 +77,13 @@ public class CMISRelationshipTypeDefinition extends CMISAbstractTypeDefinition
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
|
||||
|
||||
creatable = false;
|
||||
queryable = false;
|
||||
controllable = false;
|
||||
|
||||
if (assocDef == null)
|
||||
{
|
||||
// TODO: Add CMIS Association mapping??
|
||||
creatable = false;
|
||||
displayName = (cmisClassDef.getTitle() != null) ? cmisClassDef.getTitle() : typeId.getId();
|
||||
objectTypeQueryName = typeId.getId();
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
@ -95,6 +95,7 @@ public class CMISRelationshipTypeDefinition extends CMISAbstractTypeDefinition
|
||||
}
|
||||
else
|
||||
{
|
||||
creatable = true;
|
||||
displayName = (assocDef.getTitle() != null) ? assocDef.getTitle() : typeId.getId();
|
||||
objectTypeQueryName = cmisMapping.buildPrefixEncodedString(typeId.getQName(), false);
|
||||
parentTypeId = CMISDictionaryModel.RELATIONSHIP_TYPE_ID;
|
||||
|
@ -32,6 +32,7 @@ import org.alfresco.cmis.CMISPropertyLuceneBuilder;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
@ -152,5 +153,8 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
@ -197,6 +197,8 @@ public class CMISMapping implements InitializingBean
|
||||
registerPropertyAccessor(new ContentStreamUriProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new ParentProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS, null));
|
||||
registerPropertyAccessor(new SourceIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new TargetIdProperty(serviceRegistry));
|
||||
|
||||
//
|
||||
// Action Evaluator Mappings
|
||||
|
@ -25,14 +25,20 @@
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISRelationshipDirectionEnum;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.CMISTypesFilterEnum;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@ -46,6 +52,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
@ -55,6 +62,8 @@ import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.QNamePattern;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.AbstractLifecycleBean;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@ -450,6 +459,82 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISServices#getRelationship(org.alfresco.cmis.CMISTypeDefinition, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public AssociationRef getRelationship(CMISTypeDefinition relDef, NodeRef source, NodeRef target)
|
||||
{
|
||||
if (relDef == null)
|
||||
{
|
||||
relDef = cmisDictionaryService.findType(CMISDictionaryModel.RELATIONSHIP_TYPE_ID);
|
||||
}
|
||||
if (!relDef.getBaseType().getTypeId().equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type Id " + relDef.getTypeId() + " is not a relationship type");
|
||||
}
|
||||
|
||||
QName relDefQName = relDef.getTypeId().getQName();
|
||||
List<AssociationRef> assocs = nodeService.getTargetAssocs(source, new RegexQNamePattern(relDefQName.getNamespaceURI(), relDefQName.getLocalName()));
|
||||
for (AssociationRef assoc : assocs)
|
||||
{
|
||||
if (assoc.getTargetRef().equals(target))
|
||||
{
|
||||
return assoc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISServices#getRelationships(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.cmis.CMISTypeId, boolean, org.alfresco.cmis.CMISRelationshipDirectionEnum)
|
||||
*/
|
||||
public AssociationRef[] getRelationships(NodeRef node, CMISTypeDefinition relDef, boolean includeSubTypes, CMISRelationshipDirectionEnum direction)
|
||||
{
|
||||
// establish relationship type to filter on
|
||||
if (relDef == null)
|
||||
{
|
||||
relDef = cmisDictionaryService.findType(CMISDictionaryModel.RELATIONSHIP_TYPE_ID);
|
||||
}
|
||||
if (!relDef.getBaseType().getTypeId().equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type Id " + relDef.getTypeId() + " is not a relationship type");
|
||||
}
|
||||
|
||||
// retrieve associations
|
||||
List<AssociationRef> assocs = new ArrayList<AssociationRef>();
|
||||
if (direction == CMISRelationshipDirectionEnum.SOURCE || direction == CMISRelationshipDirectionEnum.BOTH)
|
||||
{
|
||||
assocs.addAll(nodeService.getTargetAssocs(node, RegexQNamePattern.MATCH_ALL));
|
||||
}
|
||||
if (direction == CMISRelationshipDirectionEnum.TARGET || direction == CMISRelationshipDirectionEnum.BOTH)
|
||||
{
|
||||
assocs.addAll(nodeService.getSourceAssocs(node, RegexQNamePattern.MATCH_ALL));
|
||||
}
|
||||
|
||||
// filter association by type
|
||||
Collection<CMISTypeDefinition> subRelDefs = (includeSubTypes ? relDef.getSubTypes(true) : null);
|
||||
List<AssociationRef> filteredAssocs = new ArrayList<AssociationRef>(assocs.size());
|
||||
for (AssociationRef assoc : assocs)
|
||||
{
|
||||
CMISTypeDefinition assocTypeDef = cmisDictionaryService.findTypeForClass(assoc.getTypeQName(), CMISScope.RELATIONSHIP);
|
||||
if (assocTypeDef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Association Type QName " + assoc.getTypeQName() + " does not map to a CMIS Relationship Type");
|
||||
}
|
||||
|
||||
if (assocTypeDef.equals(relDef) || (subRelDefs != null && subRelDefs.contains(assocTypeDef)))
|
||||
{
|
||||
filteredAssocs.add(assoc);
|
||||
}
|
||||
}
|
||||
|
||||
AssociationRef[] assocArray = new AssociationRef[filteredAssocs.size()];
|
||||
filteredAssocs.toArray(assocArray);
|
||||
return assocArray;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISServices#getProperty(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
@ -470,6 +555,26 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
|
||||
return propDef.getPropertyAccessor().getValue(nodeRef);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISServices#getProperty(org.alfresco.service.cmr.repository.AssociationRef, java.lang.String)
|
||||
*/
|
||||
public Serializable getProperty(AssociationRef assocRef, String propertyName)
|
||||
{
|
||||
QName typeQName = assocRef.getTypeQName();
|
||||
CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName);
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Relationship Type " + typeQName + " not found in CMIS Dictionary");
|
||||
}
|
||||
CMISPropertyDefinition propDef = cmisDictionaryService.findProperty(propertyName, typeDef);
|
||||
if (propDef == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property " + propertyName + " not found for relationship type " + typeDef.getTypeId() + " in CMIS Dictionary");
|
||||
}
|
||||
return propDef.getPropertyAccessor().getValue(assocRef);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISServices#getProperties(org.alfresco.service.cmr.repository.NodeRef)
|
||||
|
@ -29,6 +29,7 @@ import java.io.Serializable;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@ -75,6 +76,15 @@ public class DirectProperty extends AbstractSimpleProperty
|
||||
return getServiceRegistry().getNodeService().getProperty(nodeRef, alfrescoName);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLuceneFieldName()
|
||||
{
|
||||
StringBuilder field = new StringBuilder(64);
|
||||
|
@ -32,6 +32,7 @@ import java.util.regex.Pattern;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
@ -73,6 +74,15 @@ public class FixedValueProperty extends AbstractProperty
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
|
@ -35,6 +35,7 @@ import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.apache.lucene.index.Term;
|
||||
@ -64,7 +65,7 @@ public class ObjectIdProperty extends AbstractProperty
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
{
|
||||
@ -85,6 +86,16 @@ public class ObjectIdProperty extends AbstractProperty
|
||||
return nodeRef.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
// TODO: determine appropriate id for associations
|
||||
return assocRef.getSourceRef().toString();
|
||||
}
|
||||
|
||||
public String getLuceneFieldName()
|
||||
{
|
||||
return "ID";
|
||||
|
@ -30,11 +30,13 @@ import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISQueryException;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@ -65,7 +67,7 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
{
|
||||
@ -73,6 +75,15 @@ public class ObjectTypeIdProperty extends AbstractProperty
|
||||
return getServiceRegistry().getCMISDictionaryService().findTypeForClass(type).getTypeId().getId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
QName type = assocRef.getTypeQName();
|
||||
return getServiceRegistry().getCMISDictionaryService().findTypeForClass(type, CMISScope.RELATIONSHIP).getTypeId().getId();
|
||||
}
|
||||
|
||||
public String getLuceneFieldName()
|
||||
{
|
||||
|
58
source/java/org/alfresco/cmis/mapping/SourceIdProperty.java
Normal file
58
source/java/org/alfresco/cmis/mapping/SourceIdProperty.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
|
||||
/**
|
||||
* Accessor for the Source Id (relationship)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class SourceIdProperty extends AbstractProperty
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public SourceIdProperty(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
super(serviceRegistry, CMISDictionaryModel.PROP_SOURCE_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
return assocRef.getSourceRef().toString();
|
||||
}
|
||||
}
|
58
source/java/org/alfresco/cmis/mapping/TargetIdProperty.java
Normal file
58
source/java/org/alfresco/cmis/mapping/TargetIdProperty.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
|
||||
/**
|
||||
* Accessor for the Target Id (relationship)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class TargetIdProperty extends AbstractProperty
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public TargetIdProperty(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
super(serviceRegistry, CMISDictionaryModel.PROP_TARGET_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
return assocRef.getTargetRef().toString();
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ import java.io.Serializable;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
@ -85,6 +86,11 @@ public class Association implements Scopeable, Serializable
|
||||
return assocRef.getTypeQName().toString();
|
||||
}
|
||||
|
||||
public QName getTypeQName()
|
||||
{
|
||||
return assocRef.getTypeQName();
|
||||
}
|
||||
|
||||
public ScriptNode getSource()
|
||||
{
|
||||
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, this.scope, null, assocRef.getSourceRef());
|
||||
|
@ -1361,13 +1361,14 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
|
||||
* @param target Destination node for the association
|
||||
* @param assocType Association type qname (short form or fully qualified)
|
||||
*/
|
||||
public void createAssociation(ScriptNode target, String assocType)
|
||||
public Association createAssociation(ScriptNode target, String assocType)
|
||||
{
|
||||
ParameterCheck.mandatory("Target", target);
|
||||
ParameterCheck.mandatoryString("Association Type Name", assocType);
|
||||
|
||||
this.nodeService.createAssociation(this.nodeRef, target.nodeRef, createQName(assocType));
|
||||
AssociationRef assocRef = this.nodeService.createAssociation(this.nodeRef, target.nodeRef, createQName(assocType));
|
||||
reset();
|
||||
return new Association(this.services, assocRef);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,6 @@
|
||||
package org.alfresco.repo.template;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -34,6 +33,7 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.processor.ProcessorExtension;
|
||||
import org.alfresco.repo.processor.BaseProcessor;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateException;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
@ -332,6 +332,11 @@ public class FreeMarkerProcessor extends BaseProcessor implements TemplateProces
|
||||
return new TemplateNode((NodeRef)value, this.services, imageResolver);
|
||||
}
|
||||
|
||||
else if (value instanceof AssociationRef)
|
||||
{
|
||||
return new TemplateAssociation((AssociationRef)value, this.services, imageResolver);
|
||||
}
|
||||
|
||||
else if (value instanceof Map)
|
||||
{
|
||||
Map<Object, Object> map = (Map<Object, Object>)value;
|
||||
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.template;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Object representing an association
|
||||
*/
|
||||
public class TemplateAssociation implements Serializable
|
||||
{
|
||||
/** Serial version UUID*/
|
||||
private static final long serialVersionUID = -2903588739741433082L;
|
||||
|
||||
/** Service registry **/
|
||||
private ServiceRegistry services;
|
||||
|
||||
/** Association reference **/
|
||||
private AssociationRef assocRef;
|
||||
|
||||
/** Image Resolver **/
|
||||
private TemplateImageResolver resolver;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param services
|
||||
* @param assocRef
|
||||
*/
|
||||
public TemplateAssociation(AssociationRef assocRef, ServiceRegistry services, TemplateImageResolver resolver)
|
||||
{
|
||||
this.assocRef = assocRef;
|
||||
this.services = services;
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
public AssociationRef getAssociationRef()
|
||||
{
|
||||
return this.assocRef;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return assocRef.getTypeQName().toString();
|
||||
}
|
||||
|
||||
public QName getTypeQName()
|
||||
{
|
||||
return assocRef.getTypeQName();
|
||||
}
|
||||
|
||||
public TemplateNode getSource()
|
||||
{
|
||||
return new TemplateNode(assocRef.getSourceRef(), services, resolver);
|
||||
}
|
||||
|
||||
public TemplateNode getTarget()
|
||||
{
|
||||
return new TemplateNode(assocRef.getTargetRef(), services, resolver);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user