org.alfresco.service.cmr.dictionary.PropertyDefinition Java Examples

The following examples show how to use org.alfresco.service.cmr.dictionary.PropertyDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DirectLuceneBuilder.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E
{
    String field = getLuceneFieldName();
    // need to find the real field to use
    PropertyDefinition propertyDef = dictionaryService.getProperty(QName.createQName(field.substring(1)));

    if (propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
    {
        throw new CmisInvalidArgumentException("Order on content properties is not curently supported");
    }
    else if ((propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT)) || (propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT)))
    {
        field = lqpa.getSortField(field);
    }
    else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
    {
        field = lqpa.getDatetimeSortField(field, propertyDef);
    }        

    return field;
}
 
Example #2
Source File: CustomModelsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<CustomModelProperty> convertToCustomModelProperty(ClassDefinition classDefinition, boolean includeInherited)
{
    Collection<PropertyDefinition> ownProperties = null;
    ClassDefinition parentDef = classDefinition.getParentClassDefinition();
    if (!includeInherited && parentDef != null)
    {
        // Remove inherited properties
        ownProperties = removeRightEntries(classDefinition.getProperties(), parentDef.getProperties()).values();
    }
    else
    {
        ownProperties = classDefinition.getProperties().values();
    }

    List<CustomModelProperty> customProperties = new ArrayList<>(ownProperties.size());
    for (PropertyDefinition propDef : ownProperties)
    {
        customProperties.add(new CustomModelProperty(propDef, dictionaryService));
    }

    return customProperties;
}
 
Example #3
Source File: DictionaryDAOImpl.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Collection<PropertyDefinition> getProperties(QName modelName,
        QName dataType)
{
    HashSet<PropertyDefinition> properties = new HashSet<PropertyDefinition>();

    Collection<PropertyDefinition> props = getProperties(modelName);
    for (PropertyDefinition prop : props)
    {
        if ((dataType == null)
                || prop.getDataType().getName().equals(dataType))
        {
            properties.add(prop);
        }
    }
    return properties;
}
 
Example #4
Source File: RepoDictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testPropertyOverride()
{
    TypeDefinition type1 = service.getType(QName.createQName(TEST_URL, "overridetype1"));
    Map<QName, PropertyDefinition> props1 = type1.getProperties();
    PropertyDefinition prop1 = props1.get(QName.createQName(TEST_URL, "propoverride"));
    String def1 = prop1.getDefaultValue();
    assertEquals("one", def1);
    
    TypeDefinition type2 = service.getType(QName.createQName(TEST_URL, "overridetype2"));
    Map<QName, PropertyDefinition> props2 = type2.getProperties();
    PropertyDefinition prop2 = props2.get(QName.createQName(TEST_URL, "propoverride"));
    String def2 = prop2.getDefaultValue();
    assertEquals("two", def2);

    TypeDefinition type3 = service.getType(QName.createQName(TEST_URL, "overridetype3"));
    Map<QName, PropertyDefinition> props3 = type3.getProperties();
    PropertyDefinition prop3 = props3.get(QName.createQName(TEST_URL, "propoverride"));
    String def3 = prop3.getDefaultValue();
    assertEquals("three", def3);
}
 
Example #5
Source File: ModelValidatorImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void validateDeleteProperty(QName modelName, QName propertyQName, boolean sharedModel)
{
    String tenantDomain = TenantService.DEFAULT_DOMAIN;
    if (sharedModel)
    {
        tenantDomain = " for tenant [" + tenantService.getCurrentUserDomain() + "]";
    }

    PropertyDefinition prop = dictionaryDAO.getProperty(propertyQName);
    if(prop != null && prop.getName().equals(propertyQName) && prop.getModel().getName().equals(modelName))
    {
        validateDeleteProperty(tenantDomain, prop);
    }
    else
    {
        throw new AlfrescoRuntimeException("Cannot delete model " + modelName + " in tenant " + tenantDomain
                + " - property definition '" + propertyQName + "' not defined in model '" + modelName + "'");
    }
}
 
Example #6
Source File: NodeContext.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Adds a collection property to the node
 * 
 * @param property QName
 */
public void addPropertyCollection(QName property)
{
    // Do not import properties of sys:referenceable or cm:versionable or cm:copiedfrom
    // TODO: Make this configurable...
    PropertyDefinition propDef = getDictionaryService().getProperty(property);
    ClassDefinition classDef = (propDef == null) ? null : propDef.getContainerClass();
    if (classDef != null)
    {
        if (!isImportableClass(classDef.getName()))
        {
            return;
        }
    }
    
    // create collection and assign to property
    List<Serializable>values = new ArrayList<Serializable>();
    nodeProperties.put(property, (Serializable)values);
}
 
Example #7
Source File: AbstractDictionaryRegistry.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected PropertyDefinition getPropertyImpl(QName propertyName)
{
	PropertyDefinition propDef = null;

    List<CompiledModel> models = getModelsForUri(propertyName.getNamespaceURI());
    if(models != null && models.size() > 0)
    {
     for (CompiledModel model : models)
     {
     	propDef = model.getProperty(propertyName);
     	if(propDef != null)
     	{
     		break;
     	}
     }
    }

    return propDef;
}
 
Example #8
Source File: SOLRTrackingComponentImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected Map<QName, Serializable> getProperties(Long nodeId)
{
    Map<QName, Serializable> props = null;

    // ALF-10641
    // Residual properties are un-indexed -> break serlialisation
    nodeDAO.setCheckNodeConsistency();
    Map<QName, Serializable> sourceProps = nodeDAO.getNodeProperties(nodeId);
    props = new HashMap<QName, Serializable>((int)(sourceProps.size() * 1.3));
    for(QName propertyQName : sourceProps.keySet())
    {
        PropertyDefinition propDef = dictionaryService.getProperty(propertyQName);
        if(propDef != null)
        {
            props.put(propertyQName, sourceProps.get(propertyQName));
        }
    }

    return props;
}
 
Example #9
Source File: PropertyFieldProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Object getDefaultValue(QName name, ContentModelItemData<?> data)
{
    PropertyDefinition propDef = data.getPropertyDefinition(name);
    if (propDef != null)
    {
        QName typeQName = propDef.getDataType().getName();
        String strDefaultValue = propDef.getDefaultValue();
        if (NodePropertyValue.isDataTypeSupported(typeQName))
        {
            // convert to the appropriate type
            NodePropertyValue pv = new NodePropertyValue(typeQName, strDefaultValue);
            return pv.getValue(typeQName);
        }
        return strDefaultValue;
    }
    return null;
}
 
Example #10
Source File: ActivitiWorkflowServiceIntegrationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Actually tests if the priority is the default value.  This is based on the assumption that custom
 * tasks are defaulted to a priority of 50 (which is invalid).  I'm testing that the code I wrote decides this is an
 * invalid number and sets it to the default value (2).
 */
@Test
public void testPriorityIsValid()
{
    WorkflowDefinition definition = deployDefinition("activiti/testCustomActiviti.bpmn20.xml");
    
    personManager.setUser(USER1);
    
    // Start the Workflow
    WorkflowPath path = workflowService.startWorkflow(definition.getId(), null);
    String instanceId = path.getInstance().getId();

    // Check the Start Task is completed.
    WorkflowTask startTask = workflowService.getStartTask(instanceId);
    assertEquals(WorkflowTaskState.COMPLETED, startTask.getState());
    
    List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId());
    for (WorkflowTask workflowTask : tasks)
    {
        Map<QName, Serializable> props = workflowTask.getProperties();
        TypeDefinition typeDefinition = workflowTask.getDefinition().getMetadata();
        Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties();        
        PropertyDefinition priorDef =  propertyDefs.get(WorkflowModel.PROP_PRIORITY);
        assertEquals(props.get(WorkflowModel.PROP_PRIORITY),Integer.valueOf(priorDef.getDefaultValue()));        
    }
}
 
Example #11
Source File: NodeDefinitionMapperImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private NodeDefinitionProperty fromPropertyDefinitionToProperty(PropertyDefinition propertyDefinition,
        MessageLookup messageLookup)
{
    NodeDefinitionProperty property = new NodeDefinitionProperty();
    property.setId(propertyDefinition.getName().toPrefixString());
    property.setTitle(propertyDefinition.getTitle(messageLookup));
    property.setDescription(propertyDefinition.getDescription(messageLookup));
    property.setDefaultValue(propertyDefinition.getDefaultValue());
    property.setDataType(propertyDefinition.getDataType().getName().toPrefixString());
    property.setIsMultiValued(propertyDefinition.isMultiValued());
    property.setIsMandatory(propertyDefinition.isMandatory());
    property.setIsMandatoryEnforced(propertyDefinition.isMandatoryEnforced());
    property.setIsProtected(propertyDefinition.isProtected());
    property.setConstraints(getConstraints(propertyDefinition.getConstraints(), messageLookup));
   
    return property;
}
 
Example #12
Source File: FieldUtils.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Generates a list of property fields with values.
 * 
 * @param propDefs List of property definitions to generate
 * @param values Map containing the values to use for each property
 * @param group The group the field belongs to
 * @param namespaceService NamespaceService instance
 * @return List of generated Field objects
 */
public static List<Field> makePropertyFields(
            Collection<PropertyDefinition> propDefs,
            Map<PropertyDefinition, Object> values,
            FieldGroup group,
            NamespaceService namespaceService,
            DictionaryService dictionaryService)
{
    PropertyFieldProcessor processor = new PropertyFieldProcessor(namespaceService, dictionaryService);
    ArrayList<Field> fields = new ArrayList<Field>(propDefs.size());
    for (PropertyDefinition propDef : propDefs)
    {
        Object value = values == null ? null : values.get(propDef);
        Field field = processor.makeField(propDef, value, group);
        fields.add(field);
    }
    return fields;
}
 
Example #13
Source File: TypeRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_setupChangePolicies()
{
    if (this.moveStoresOnChangeOptionPropertyName != null)
    {
        this.moveStoresOnChangeOptionPropertyQName = QName.resolveToQName(this.namespaceService,
                this.moveStoresOnChangeOptionPropertyName);
        PropertyCheck.mandatory(this, "moveStoresOnChangeOptionPropertyQName", this.moveStoresOnChangeOptionPropertyQName);

        final PropertyDefinition moveStoresOnChangeOptionPropertyDefinition = this.dictionaryService
                .getProperty(this.moveStoresOnChangeOptionPropertyQName);
        if (moveStoresOnChangeOptionPropertyDefinition == null
                || !DataTypeDefinition.BOOLEAN.equals(moveStoresOnChangeOptionPropertyDefinition.getDataType().getName())
                || moveStoresOnChangeOptionPropertyDefinition.isMultiValued())
        {
            throw new IllegalStateException(this.moveStoresOnChangeOptionPropertyName
                    + " is not a valid content model property of type single-valued d:boolean");
        }
    }

    if (this.moveStoresOnChange || this.moveStoresOnChangeOptionPropertyQName != null)
    {
        this.policyComponent.bindClassBehaviour(OnSetNodeTypePolicy.QNAME, ContentModel.TYPE_BASE,
                new JavaBehaviour(this, "onSetNodeType", NotificationFrequency.EVERY_EVENT));
    }
}
 
Example #14
Source File: AbstractWorkflowPropertyHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected Object handleDefaultProperty(Object task, TypeDefinition type, QName key, Serializable value)
{
    PropertyDefinition propDef = type.getProperties().get(key);
    if (propDef != null)
    {
        return handleProperty(value, propDef);
    }
    else
    {
        AssociationDefinition assocDef = type.getAssociations().get(key);
        if (assocDef != null)
        {
            return handleAssociation(value, assocDef);
        }
        else if (value instanceof NodeRef)
        {
            return nodeConverter.convertNode((NodeRef)value, false);
        }
    }
    return value;
}
 
Example #15
Source File: AbstractWorkflowPropertyHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected Object convertPropertyValue(PropertyDefinition propDef, Serializable value)
{
    Object newValue = value;
    // Convert property value using a default type converter
    if (value instanceof Collection<?>)
    {
        // Convert a collecion of values
        newValue =typeConverter.convert(propDef.getDataType(), (Collection<?>) value);
    }
    else
    {
        // Convert a single value
        newValue = typeConverter.convert(propDef.getDataType(), value);
    }

    // Convert NodeRefs to ActivitiScriptNodes
    DataTypeDefinition dataTypeDef = propDef.getDataType();
    if (dataTypeDef.getName().equals(DataTypeDefinition.NODE_REF))
    {
        newValue = nodeConverter.convertNodes(newValue, propDef.isMultiValued());
    }
    return newValue;
}
 
Example #16
Source File: RepoDictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testLabels()
{
    QName model = QName.createQName(TEST_URL, "dictionarydaotest");
    ModelDefinition modelDef = service.getModel(model);
    assertEquals("Model Description", modelDef.getDescription(service));
    QName type = QName.createQName(TEST_URL, "base");
    TypeDefinition typeDef = service.getType(type);
    assertEquals("Base Title", typeDef.getTitle(service));
    assertEquals("Base Description", typeDef.getDescription(service));
    QName prop = QName.createQName(TEST_URL, "prop1");
    PropertyDefinition propDef = service.getProperty(prop);
    assertEquals("Prop1 Title", propDef.getTitle(service));
    assertEquals("Prop1 Description", propDef.getDescription(service));
    QName assoc = QName.createQName(TEST_URL, "assoc1");
    AssociationDefinition assocDef = service.getAssociation(assoc);
    assertEquals("Assoc1 Title", assocDef.getTitle(service));
    assertEquals("Assoc1 Description", assocDef.getDescription(service));
    QName datatype = QName.createQName(TEST_URL, "datatype");
    DataTypeDefinition datatypeDef = service.getDataType(datatype);
    assertEquals("alfresco/model/dataTypeAnalyzers", datatypeDef.getAnalyserResourceBundleName());
}
 
Example #17
Source File: CommonFacadingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_setupHandleContentProperties()
{
    if (this.handleContentPropertyNames != null && !this.handleContentPropertyNames.isEmpty())
    {
        this.handleContentPropertyQNames = new HashSet<>();
        for (final String facadePropertyName : this.handleContentPropertyNames)
        {
            final QName routePropertyQName = QName.resolveToQName(this.namespaceService, facadePropertyName);
            ParameterCheck.mandatory("routePropertyQName", routePropertyQName);

            final PropertyDefinition contentPropertyDefinition = this.dictionaryService.getProperty(routePropertyQName);
            if (contentPropertyDefinition == null
                    || !DataTypeDefinition.CONTENT.equals(contentPropertyDefinition.getDataType().getName()))
            {
                throw new IllegalStateException(facadePropertyName + " is not a valid content model property of type d:content");
            }
            this.handleContentPropertyQNames.add(routePropertyQName);
        }
    }
}
 
Example #18
Source File: AbstractShardInformationPublisher.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Given the field name, returns the name of the property definition.
 * If the property definition is not found, Empty optional is returned.
 *
 * @param field the field name.
 * @return the name of the associated property definition if present, Optional.Empty() otherwise
 */
static Optional<QName> getShardProperty(String field)
{
    if (StringUtils.isBlank(field))
    {
        throw new IllegalArgumentException("Sharding property " + SHARD_KEY_KEY + " has not been set.");
    }

    AlfrescoSolrDataModel dataModel = AlfrescoSolrDataModel.getInstance();
    NamespaceDAO namespaceDAO = dataModel.getNamespaceDAO();
    DictionaryService dictionaryService = dataModel.getDictionaryService(CMISStrictDictionaryService.DEFAULT);
    PropertyDefinition propertyDef = QueryParserUtils.matchPropertyDefinition("http://www.alfresco.org/model/content/1.0",
            namespaceDAO,
            dictionaryService,
            field);

    return ofNullable(propertyDef).map(PropertyDefinition::getName);
}
 
Example #19
Source File: SolrInformationServerTest.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void destructuringCanBeAppliedOnlyToDateOrDatetimeFields()
{
    Stream.of(ANY,ENCRYPTED,TEXT,MLTEXT,CONTENT,INT,LONG,FLOAT,DOUBLE,
            BOOLEAN,QNAME,CATEGORY,NODE_REF,CHILD_ASSOC_REF,ASSOC_REF,
            PATH,LOCALE,PERIOD)
            .map(qname -> {
                PropertyDefinition propertyThatCannotBeDestructured = mock(PropertyDefinition.class);
                DataTypeDefinition def = Mockito.mock(DataTypeDefinition.class);
                when(def.getName()).thenReturn(qname);
                when(propertyThatCannotBeDestructured.getDataType()).thenReturn(def);
                return propertyThatCannotBeDestructured;})
            .forEach(property -> assertFalse(
                            "Destructuring must be supported only on Date or Datetime fields!",
                            infoServer.canBeDestructured(property, "somedatatype@sd@{http://www.alfresco.org/model/content/1.0}somefield")));
}
 
Example #20
Source File: ActivitiPropertyConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isMandatory(ClassAttributeDefinition definition)
{
    if(definition instanceof PropertyDefinition)
    {
        PropertyDefinition propDef = (PropertyDefinition) definition;
        return propDef.isMandatory();
    }
    AssociationDefinition assocDSef = (AssociationDefinition) definition;
    return assocDSef.isTargetMandatory();
}
 
Example #21
Source File: ModelValidatorImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateDeleteProperty(final String tenantDomain, final PropertyDefinition propDef)
{
    final QName propName = propDef.getName();

    // We need a separate transaction to do the qname delete "check"
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            return TenantUtil.runAsTenant(new TenantRunAsWork<Void>()
            {
                @Override
                public Void doWork() throws Exception
                {
                    try
                    {
                        // The property QName may not have been created in the database if no
                        // properties have been created that use it, so check first and then
                        // try to delete it.
                        if(qnameDAO.getQName(propName) != null)
                        {
                            qnameDAO.deleteQName(propName);
                        }
                    }
                    catch(DataIntegrityViolationException e)
                    {
                        // catch data integrity violation e.g. foreign key constraint exception
                        logger.debug(e);
                        throw new ModelInUseException("Failed to validate property delete, property " + propName + " is in use");
                    }

                    return null;
                }
            }, tenantDomain);
        }
    }, false, true);
}
 
Example #22
Source File: TaskFormProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Map<QName, PropertyDefinition> makeTaskPropertyDefs()
{
    Map<QName, PropertyDefinition> properties = new HashMap<QName, PropertyDefinition>();
    QName textType = DataTypeDefinition.TEXT;

    // Add a Description property
    PropertyDefinition descValue = MockClassAttributeDefinition.mockPropertyDefinition(DESC_NAME, textType);
    properties.put(DESC_NAME, descValue);

    // Add a Status property
    PropertyDefinition titleValue = MockClassAttributeDefinition.mockPropertyDefinition(STATUS_NAME, textType);
    properties.put(STATUS_NAME, titleValue);

    // Add a Status property
    PropertyDefinition with_ = MockClassAttributeDefinition.mockPropertyDefinition(PROP_WITH_, textType);
    properties.put(PROP_WITH_, with_);

    // Add a Package Action property
    QName pckgActionGroup = PROP_PACKAGE_ACTION_GROUP;
    PropertyDefinition pckgAction = MockClassAttributeDefinition.mockPropertyDefinition(pckgActionGroup, textType,
                "");
    properties.put(pckgActionGroup, pckgAction);

    // Add a Package Action property
    QName pckgItemActionGroup = PROP_PACKAGE_ITEM_ACTION_GROUP;
    PropertyDefinition pckgItemAction = MockClassAttributeDefinition.mockPropertyDefinition(pckgItemActionGroup,
                textType, "read_package_item_actions");
    properties.put(pckgItemActionGroup, pckgItemAction);
    
    
    // Add a priority property
    QName priorityName = PROP_PRIORITY;
    PropertyDefinition priorityDef = 
        MockClassAttributeDefinition.mockPropertyDefinition(priorityName, DataTypeDefinition.INT, Integer.class, "0");
    properties.put(priorityName, priorityDef);

    return properties;
}
 
Example #23
Source File: SolrInformationServerTest.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void destructuringCanBeAppliedToDateTimeFields()
{
    PropertyDefinition propertyThatCanBeDestructured = mock(PropertyDefinition.class);
    when(propertyThatCanBeDestructured.isMultiValued()).thenReturn(false);

    DataTypeDefinition datetime = mock(DataTypeDefinition.class);
    when(datetime.getName()).thenReturn(DataTypeDefinition.DATETIME);
    when(propertyThatCanBeDestructured.getDataType()).thenReturn(datetime);

    assertTrue(
            "Destructuring must be supported in Datetime fields!",
            infoServer.canBeDestructured(propertyThatCanBeDestructured, "datetime@sd@{http://www.alfresco.org/model/content/1.0}created"));
}
 
Example #24
Source File: SolrInformationServerTest.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void destructuringCannotBeAppliedToMultivaluedFields()
{
    PropertyDefinition multiValuedProperty = mock(PropertyDefinition.class);
    when(multiValuedProperty.isMultiValued()).thenReturn(true);

    assertFalse(infoServer.canBeDestructured(multiValuedProperty, "datetime@sd@{http://www.alfresco.org/model/content/1.0}created"));
}
 
Example #25
Source File: FieldProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ContentModelItemData<Void> makeItemData()
{
    Map<QName, PropertyDefinition> propDefs = makePropertyDefs();
    Map<QName, AssociationDefinition> assocDefs = makeAssociationDefs();
    
    Map<QName, Serializable> propValues = new HashMap<QName, Serializable>();
    Map<QName, Serializable> assocValues = new HashMap<QName, Serializable>();
    Map<String, Object> transientValues = new HashMap<String, Object>();
    return new ContentModelItemData<Void>(null, propDefs, assocDefs, propValues, assocValues, transientValues);
}
 
Example #26
Source File: FacetablePropertyFTL.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param containingPropDef     The {@link PropertyDefinition}.
 * @param localisedTitle        The localised title of this synthetic property e.g. "taille".
 * @param syntheticPropertyName The synthetic property name e.g. "size".
 * @param datatype              The datatype of the synthetic property.
 */
public SyntheticFacetablePropertyFTL(PropertyDefinition containingPropDef,
                                     String localisedTitle,
                                     String syntheticPropertyName,
                                     QName  datatype)
{
    super(localisedTitle);
    this.containingPropDef     = containingPropDef;
    this.syntheticPropertyName = syntheticPropertyName;
    this.datatype              = datatype;
    this.displayName           = getShortQname() + (localisedTitle == null ? "" : " (" + localisedTitle + ")");
}
 
Example #27
Source File: IncompleteNodeTagger.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param propertyDefs the property definitions to check
 * @param properties the properties
 * @return Returns true if the property definitions were all satisified
 */
private boolean checkProperties(
        Collection<PropertyDefinition> propertyDefs,
        Map<QName, Serializable> properties)
{
    for (PropertyDefinition propertyDef : propertyDefs)
    {
        if (propertiesToIgnore.contains(propertyDef.getName()))
        {
            continue;
        }
        
        if (!propertyDef.isMandatory())
        {
            // The property isn't mandatory in any way
            continue;
        }
        else if (propertyDef.isMandatoryEnforced())
        {
            // The mandatory nature of the property is fully enforced
            // Leave these for integrity
            continue;
        }
        // The mandatory nature of the property is 'soft' a.k.a. 'required'
        // Check that the property value has been supplied
        if (properties.get(propertyDef.getName()) == null)
        {
            // property NOT supplied
            return false;
        }
    }
    // all properties were present
    return true;
}
 
Example #28
Source File: RestVariableHelper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the variable value with possible conversion to the correct format to be used in the response and sets
 * the type accordingly. If the variables is defined on the {@link TypeDefinition}, the data-type is used. If it's not
 * defined, the type is deducted from the raw variable value.
 */
protected void setVariableValueAndType(Variable variable, Object value, TypeDefinitionContext context)
{
    PropertyDefinition propDef = context.getPropertyDefinition(variable.getName());
    if (propDef != null)
    {
        variable.setValue(getSafePropertyValue(value));
        variable.setType(propDef.getDataType().getName().toPrefixString(namespaceService));
    }
    else
    {
        // Not defined as a property, check if it's an association
        AssociationDefinition assocDef = context.getAssociationDefinition(variable.getName());
        if (assocDef == null)
        {
            // Try to get an association definition through dictionary
            String[] prefixLocalName = variable.getName().split("_");
            if (prefixLocalName.length == 2)
            {
                QName qName = QName.createQName(prefixLocalName[0], prefixLocalName[1], namespaceService);
                assocDef = dictionaryService.getAssociation(qName);
            }
        }
        
        if (assocDef != null)
        {
            // Type of variable is the target class-name
            variable.setType(assocDef.getTargetClass().getName().toPrefixString(namespaceService));
            variable.setValue(getAssociationRepresentation(value, assocDef));
        }
        else
        {
            // Variable is not declared as property or association type-def. Use actual raw value as base for conversion.
            variable.setValue(getSafePropertyValue(value));
            variable.setType(extractTypeStringFromValue(value));
        }
    }
}
 
Example #29
Source File: WorkflowModelBuilder.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Map<String, String> buildPropertyLabels(WorkflowTask task, Map<String, Object> properties)
{
    TypeDefinition taskType = task.getDefinition().getMetadata();
    final Map<QName, PropertyDefinition> propDefs = taskType.getProperties();
    return CollectionUtils.transform(properties, new Function<Entry<String, Object>, Pair<String, String>>()
    {
        @Override
        public Pair<String, String> apply(Entry<String, Object> entry)
        {
            String propName = entry.getKey();
            PropertyDefinition propDef = propDefs.get(qNameConverter.mapNameToQName(propName));
            if(propDef != null )
            {
                List<ConstraintDefinition> constraints = propDef.getConstraints();
                for (ConstraintDefinition constraintDef : constraints)
                {
                    Constraint constraint = constraintDef.getConstraint();
                    if (constraint instanceof ListOfValuesConstraint)
                    {
                        ListOfValuesConstraint listConstraint = (ListOfValuesConstraint) constraint;
                        String label = listConstraint.getDisplayLabel(String.valueOf(entry.getValue()), dictionaryService);
                        return new Pair<String, String>(propName, label);
                    }
                }
            }
            return null;
        }
    });
}
 
Example #30
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getStoredMLTextField(QName propertyQName, String suffix)
{
    PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName);

    StringBuilder sb = new StringBuilder();
    sb.append("mltext@m_stored_");

    sb.append((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.TRUE ||
        propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)? "t" : "_");

    sb.append((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE ||
        propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH ||
        isIdentifierTextProperty(propertyDefinition.getName()))? "s" : "_");

    sb.append((crossLocaleSearchDataTypes.contains(propertyDefinition.getDataType().getName()) ||
        crossLocaleSearchProperties.contains(propertyDefinition.getName())) ? "c" : "_");

    sb.append("_");

    sb.append(isSuggestable(propertyQName)? "s": "_");

    sb.append("@");
    sb.append(propertyDefinition.getName().toString());

    if (suffix != null)
    {
        sb.append(suffix);
    }

    return sb.toString();

}