Java Code Examples for org.alfresco.service.cmr.dictionary.DataTypeDefinition

The following are top voted examples for showing how to use org.alfresco.service.cmr.dictionary.DataTypeDefinition. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: alfresco-data-model   File: AbstractDictionaryRegistry.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
protected DataTypeDefinition getDataTypeImpl(Class javaClass)
   {
   	DataTypeDefinition dataTypeDef = null;

   	if (javaClass != null)
   	{
           for (CompiledModel model : getCompiledModels(true).values())
           { 
               dataTypeDef = model.getDataType(javaClass);
               if(dataTypeDef != null)
               {
                   break;
               }
           }
   	}

       return dataTypeDef;
   }
 
Example 2
Project: alfresco-data-model   File: AbstractDictionaryRegistry.java   View source code 6 votes vote down vote up
protected DataTypeDefinition getDataTypeImp(QName typeName)
{
	DataTypeDefinition dataType = null;

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

    return dataType;
}
 
Example 3
Project: alfresco-repository   File: ActionFormProcessor.java   View source code 6 votes vote down vote up
protected List<Field> generateDefaultFields(FormCreationData data, List<String> fieldsToIgnore)
{
    List<Field> fields = new ArrayList<Field>();
    
    ActionItemData itemData = (ActionItemData)data.getItemData();
    
    // generate a field for each action parameter
    for (ParameterDefinition paramDef : itemData.getActionDefinition().getParameterDefinitions())
    {
        if (!fieldsToIgnore.contains(paramDef.getName()))
        {
            ActionParameterField actionParameterField = new ActionParameterField(paramDef, actionService);
            fields.add(actionParameterField);
        }
    }
    
    // And also generate the special case of "execute asynchronously", which is not defined
    // as an ActionParameter within the ActionExecuter, but is instead available for all actions.
    fields.add(new ActionNonParameterField(EXECUTE_ASYNCHRONOUSLY, DataTypeDefinition.BOOLEAN));
    
    return fields;
}
 
Example 4
Project: alfresco-data-model   File: TypeConverter.java   View source code 6 votes vote down vote up
/**
 * General conversion method to convert collection contents to the specified
 * type. Wrapper around the Collection version for arrays.
 * 
 * @param propertyType - the target property type
 * @param values - the value to be converted
 * @return - the converted value as the correct type
 * @throws DictionaryException if the property type's registered java class is invalid
 * @throws TypeConversionException if the conversion cannot be performed
 */
public final Collection<?> convert(DataTypeDefinition propertyType, Object[] values)
{
   if(values == null) {
      return convert(propertyType, (Collection<?>)null);
   } else {
      // Turn the array into a Collection, then convert as that
      ArrayList<Object> c = new ArrayList<Object>();
      c.ensureCapacity(values.length);
      for(Object v : values) {
         c.add(v);
      }
      // Convert
      return convert(propertyType, c);
   }
}
 
Example 5
Project: alfresco-repository   File: AbstractTransformationRenderingEngine.java   View source code 6 votes vote down vote up
protected Collection<ParameterDefinition> getParameterDefinitions()
{
    Collection<ParameterDefinition> paramList = super.getParameterDefinitions();
    
    paramList.add(new ParameterDefinitionImpl(PARAM_TIMEOUT_MS, DataTypeDefinition.LONG, false,
            getParamDisplayLabel(PARAM_TIMEOUT_MS)));
    paramList.add(new ParameterDefinitionImpl(PARAM_READ_LIMIT_TIME_MS, DataTypeDefinition.LONG, false,
            getParamDisplayLabel(PARAM_READ_LIMIT_TIME_MS)));
    paramList.add(new ParameterDefinitionImpl(PARAM_MAX_SOURCE_SIZE_K_BYTES, DataTypeDefinition.LONG, false,
            getParamDisplayLabel(PARAM_MAX_SOURCE_SIZE_K_BYTES)));
    paramList.add(new ParameterDefinitionImpl(PARAM_READ_LIMIT_K_BYTES, DataTypeDefinition.LONG, false,
            getParamDisplayLabel(PARAM_READ_LIMIT_K_BYTES)));
    paramList.add(new ParameterDefinitionImpl(PARAM_MAX_PAGES, DataTypeDefinition.INT, false,
            getParamDisplayLabel(PARAM_MAX_PAGES)));
    paramList.add(new ParameterDefinitionImpl(PARAM_PAGE_LIMIT, DataTypeDefinition.INT, false,
            getParamDisplayLabel(PARAM_PAGE_LIMIT)));
    paramList.add(new ParameterDefinitionImpl(PARAM_USE, DataTypeDefinition.TEXT, false,
            getParamDisplayLabel(PARAM_USE)));
    
    return paramList;
}
 
Example 6
Project: alfresco-repository   File: AbstractWorkflowPropertyHandler.java   View source code 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 7
Project: alfresco-repository   File: ExporterActionExecuter.java   View source code 6 votes vote down vote up
/**
 * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
 */
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_PACKAGE_NAME, DataTypeDefinition.TEXT, true, 
          getParamDisplayLabel(PARAM_PACKAGE_NAME)));
    paramList.add(new ParameterDefinitionImpl(PARAM_ENCODING, DataTypeDefinition.TEXT, true, 
          getParamDisplayLabel(PARAM_ENCODING)));
    paramList.add(new ParameterDefinitionImpl(PARAM_STORE, DataTypeDefinition.TEXT, true, 
          getParamDisplayLabel(PARAM_STORE)));
    paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, true, 
          getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
    paramList.add(new ParameterDefinitionImpl(PARAM_INCLUDE_CHILDREN, DataTypeDefinition.BOOLEAN, false, 
          getParamDisplayLabel(PARAM_INCLUDE_CHILDREN)));
    paramList.add(new ParameterDefinitionImpl(PARAM_INCLUDE_SELF, DataTypeDefinition.BOOLEAN, false, 
          getParamDisplayLabel(PARAM_INCLUDE_SELF)));
}
 
Example 8
Project: alfresco-data-model   File: DirectLuceneBuilder.java   View source code 6 votes vote down vote up
@Override
protected String getRangeMax()
{
    if(getInDataType().getName().equals(DataTypeDefinition.DATE))
    {
        return "MAX";
    }
    else if(getInDataType().getName().equals(DataTypeDefinition.DATETIME))
    {
        return "MAX";
    }
    else
    {
        return super.getRangeMax();
    }
}
 
Example 9
Project: alfresco-repository   File: MetadataEncryptor.java   View source code 6 votes vote down vote up
/**
 * Decrypt a property if the data definition (model-specific) requires it.
 * 
 * @param propertyQName             the property qualified name
 * @param inbound                   the property to decrypt
 * @return                          the decrypted property or the original if it wasn't encrypted
 */
public Serializable decrypt(QName propertyQName, Serializable inbound)
{
    PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
    if (inbound == null || propertyDef == null || !(propertyDef.getDataType().getName().equals(DataTypeDefinition.ENCRYPTED)))
    {
        return inbound;
    }
    if (!(inbound instanceof SealedObject))
    {
        return inbound;
    }
    try
    {
     Serializable outbound = encryptor.unsealObject(KeyProvider.ALIAS_METADATA, inbound);
     // Done
     return outbound;
    }
    catch(KeyException e)
    {
    	throw new AlfrescoRuntimeException("Invalid metadata decryption key", e);
    }
}
 
Example 10
Project: alfresco-data-model   File: TypeConverter.java   View source code 6 votes vote down vote up
/**
 * General conversion method to convert collection contents to the specified
 * type.
 * 
 * @param propertyType - the target property type
 * @param values - the value to be converted
 * @return - the converted value as the correct type
 * @throws DictionaryException if the property type's registered java class is invalid
 * @throws TypeConversionException if the conversion cannot be performed
 */
public final Collection<?> convert(DataTypeDefinition propertyType, Collection<?> values)
{
    ParameterCheck.mandatory("Property type definition", propertyType);
    
    // Convert property type to java class
    Class<?> javaClass = null;
    String javaClassName = propertyType.getJavaClassName();
    try
    {
        javaClass = Class.forName(javaClassName);
    }
    catch (ClassNotFoundException e)
    {
        throw new DictionaryException("Java class " + javaClassName + " of property type " + propertyType.getName() + " is invalid", e);
    }
    
    return convert(javaClass, values);
}
 
Example 11
Project: alfresco-repository   File: NodeEligibleForRethumbnailingEvaluator.java   View source code 5 votes vote down vote up
/**
 * Add parameter definitions
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_THUMBNAIL_DEFINITION_NAME, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_THUMBNAIL_DEFINITION_NAME)));
    
    paramList.add(new ParameterDefinitionImpl(PARAM_RETRY_PERIOD, DataTypeDefinition.LONG, true, getParamDisplayLabel(PARAM_RETRY_PERIOD)));
    paramList.add(new ParameterDefinitionImpl(PARAM_RETRY_COUNT, DataTypeDefinition.INT, true, getParamDisplayLabel(PARAM_RETRY_COUNT)));
    
    paramList.add(new ParameterDefinitionImpl(PARAM_QUIET_PERIOD, DataTypeDefinition.LONG, true, getParamDisplayLabel(PARAM_QUIET_PERIOD)));
    paramList.add(new ParameterDefinitionImpl(PARAM_QUIET_PERIOD_RETRIES_ENABLED, DataTypeDefinition.BOOLEAN, true, getParamDisplayLabel(PARAM_QUIET_PERIOD_RETRIES_ENABLED)));
}
 
Example 12
Project: alfresco-repository   File: UpdateThumbnailActionExecuter.java   View source code 5 votes vote down vote up
/**
 * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
    paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_CONTENT_PROPERTY)));
    paramList.add(new ParameterDefinitionImpl(PARAM_THUMBNAIL_NODE, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_THUMBNAIL_NODE)));
}
 
Example 13
Project: alfresco-repository   File: AddFailedThumbnailActionExecuter.java   View source code 5 votes vote down vote up
/**
 * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_THUMBNAIL_DEFINITION_NAME, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_THUMBNAIL_DEFINITION_NAME), false));
    paramList.add(new ParameterDefinitionImpl(PARAM_FAILURE_DATETIME, DataTypeDefinition.DATETIME, true, getParamDisplayLabel(PARAM_FAILURE_DATETIME), false));
}
 
Example 14
Project: alfresco-repository   File: CreateThumbnailActionExecuter.java   View source code 5 votes vote down vote up
/**
 * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
    paramList.add(new ParameterDefinitionImpl(PARAM_THUMBANIL_NAME, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_THUMBANIL_NAME)));      
    paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_CONTENT_PROPERTY)));        
}
 
Example 15
Project: alfresco-repository   File: SizeFieldProcessor.java   View source code 5 votes vote down vote up
@Override
protected FieldDefinition makeTransientFieldDefinition() 
{
    String dataKeyName = PROP_DATA_PREFIX + KEY;
    PropertyFieldDefinition sizeField = new PropertyFieldDefinition(KEY, 
                DataTypeDefinition.LONG.getLocalName());
    sizeField.setLabel(I18NUtil.getMessage(MSG_SIZE_LABEL));
    sizeField.setDescription(I18NUtil.getMessage(MSG_SIZE_DESC));
    sizeField.setDataKeyName(dataKeyName);
    sizeField.setProtectedField(true);
    return sizeField;
}
 
Example 16
Project: alfresco-remote-api   File: CustomModelsImpl.java   View source code 5 votes vote down vote up
@Override
public void validateUsage(QName propDataType)
{
    if (propDataType != null && !(DataTypeDefinition.TEXT.equals(propDataType)
                || DataTypeDefinition.MLTEXT.equals(propDataType)
                || DataTypeDefinition.CONTENT.equals(propDataType)))
    {
        throw new InvalidArgumentException("cmm.rest_api.length_constraint_invalid_use");
    }
}
 
Example 17
Project: alfresco-repository   File: AncestorNodeLocator.java   View source code 5 votes vote down vote up
/**
* {@inheritDoc}
*/
@Override
public List<ParameterDefinition> getParameterDefinitions()
{
    List<ParameterDefinition> paramDefs = new ArrayList<ParameterDefinition>(2);
    paramDefs.add(new ParameterDefinitionImpl(TYPE_KEY, DataTypeDefinition.QNAME, false, "Type"));
    paramDefs.add(new ParameterDefinitionImpl(ASPECT_KEY, DataTypeDefinition.QNAME, false, "Aspect"));
    return paramDefs;
}
 
Example 18
Project: alfresco-data-model   File: ParentLuceneBuilder.java   View source code 5 votes vote down vote up
private <Q, S, E extends Throwable> String getValueAsString(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value)
{
	String nodeRefStr = (String)value;
    if(!NodeRef.isNodeRef((String)value))
    {
        // assume the value (object id) is the node guid
        StoreRef storeRef = getStore(lqpa);
    	nodeRefStr = storeRef.toString() + "/" + (String)value;
    }

    Object converted = DefaultTypeConverter.INSTANCE.convert(dictionaryService.getDataType(DataTypeDefinition.NODE_REF), nodeRefStr);
    String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted);
    return asString;
}
 
Example 19
Project: alfresco-data-model   File: QueryParserUtils.java   View source code 5 votes vote down vote up
public static DataTypeDefinition matchDataTypeDefinition(String defaultNameSpaceUri, NamespacePrefixResolver namespacePrefixResolver, DictionaryService dictionaryService, String string) 
{
    QName search = QName.createQName(QueryParserUtils.expandQName(defaultNameSpaceUri, namespacePrefixResolver, string));
    DataTypeDefinition dataTypeDefinition = dictionaryService.getDataType(QName.createQName(QueryParserUtils.expandQName(defaultNameSpaceUri, namespacePrefixResolver, string)));
    QName match = null;
    if (dataTypeDefinition == null)
    {
        for (QName definition : dictionaryService.getAllDataTypes())
        {
            if (definition.getNamespaceURI().equalsIgnoreCase(search.getNamespaceURI()))
            {
                if (definition.getLocalName().equalsIgnoreCase(search.getLocalName()))
                {
                    if (match == null)
                    {
                        match = definition;
                    }
                    else
                    {
                        throw new DictionaryException("Ambiguous data datype " + string);
                    }
                }
            }

        }
    }
    else
    {
        return dataTypeDefinition;
    }
    if (match == null)
    {
        return null;
    }
    else
    {
        return dictionaryService.getDataType(match);
    }
}
 
Example 20
Project: alfresco-repository   File: SolrFacetServiceImpl.java   View source code 5 votes vote down vote up
@Override public List<SyntheticPropertyDefinition> getFacetableSyntheticProperties(QName contentClass)
{
    final List<SyntheticPropertyDefinition> result = new ArrayList<>();
    
    final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass);
    
    if (propertyDefs != null)
    {
        for (final Map.Entry<QName, PropertyDefinition> prop : propertyDefs.entrySet())
        {
            final PropertyDefinition propDef = prop.getValue();
            
            // Only properties of type cm:content can expand to synthetic properties.
            if (DataTypeDefinition.CONTENT.equals(propDef.getDataType().getName()))
            {
                // We do not want to treat the cm:content property itself as facetable.
                // It is a content URL whose value is not suitable for facetting.
                //   e.g. 2010/1/22/13/14/6e228904-d5d2-4a99-b7b1-8fe7c03c71f3.bin|mimetype=application/octet-stream|size=728|encoding=UTF-8|locale=en_GB_
                //
                // However there are elements within that content URL which *are* facetable and are correctly treated as such by SOLR.
                // As these are not actually Alfresco content properties, we must return artificial PropertyDefinition objects:
                result.add(new SyntheticPropertyDefinition(propDef, "size", DataTypeDefinition.LONG));
                result.add(new SyntheticPropertyDefinition(propDef, "mimetype", DataTypeDefinition.TEXT));
            }
            else
            {
                // Intentionally empty. Only cm:content's size and mimetype are currently supported.
            }
        }
    }
    
    return result;
}
 
Example 21
Project: alfresco-repository   File: SolrFacetServiceImpl.java   View source code 5 votes vote down vote up
private boolean isNumeric(DataTypeDefinition datatype)
{
    boolean result;
    try
    {
        Class<?> clazz = Class.forName(datatype.getJavaClassName());
        result = Number.class.isAssignableFrom(clazz);
    } catch (ClassNotFoundException e)
    {
        result = false;
    }
    return result;
}
 
Example 22
Project: alfresco-repository   File: ParameterDefinitionImplTest.java   View source code 5 votes vote down vote up
private ParameterDefinitionImpl create()
{
    ParameterDefinitionImpl paramDef = new ParameterDefinitionImpl(
            NAME,
            DataTypeDefinition.TEXT,
            true,
            DISPLAY_LABEL);
    assertNotNull(paramDef);
    return paramDef;
}
 
Example 23
Project: alfresco-repository   File: DBQuery.java   View source code 5 votes vote down vote up
public static DataTypeDefinition getDataTypeDefinition(DictionaryService dictionaryService, QName propertyQname)
{
    if(propertyQname == null)
    {
        return null;
    }
    PropertyDefinition propDef = dictionaryService.getProperty(propertyQname);
    if(propDef == null)
    {
        return null;
    }
    return propDef.getDataType();
}
 
Example 24
Project: alfresco-repository   File: PerformRenditionActionExecuter.java   View source code 5 votes vote down vote up
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
    paramList.add(new ParameterDefinitionImpl(PARAM_RENDITION_DEFINITION, DataTypeDefinition.ANY, true,
                getParamDisplayLabel(PARAM_RENDITION_DEFINITION)));

    paramList.add(new ParameterDefinitionImpl(PARAM_RESULT, DataTypeDefinition.CHILD_ASSOC_REF, false,
                getParamDisplayLabel(PARAM_RESULT)));
}
 
Example 25
Project: alfresco-repository   File: ReformatRenderingEngine.java   View source code 5 votes vote down vote up
@Override
protected Collection<ParameterDefinition> getParameterDefinitions()
{
    Collection<ParameterDefinition> paramList = super.getParameterDefinitions();
    paramList.add(new ParameterDefinitionImpl(PARAM_MIME_TYPE, DataTypeDefinition.TEXT, true,
                getParamDisplayLabel(PARAM_MIME_TYPE)));
    paramList.add(new ParameterDefinitionImpl(PARAM_FLASH_VERSION, DataTypeDefinition.TEXT, false,
                getParamDisplayLabel(PARAM_FLASH_VERSION)));
    return paramList;
}
 
Example 26
Project: alfresco-repository   File: AbstractRenderingEngine.java   View source code 5 votes vote down vote up
/**
 * Supplies the list of parameters required by this rendering engine.
 * 
 */
protected Collection<ParameterDefinition> getParameterDefinitions()
{
    List<ParameterDefinition> paramList = new ArrayList<ParameterDefinition>();
    
    paramList.add(new ParameterDefinitionImpl(RenditionDefinitionImpl.RENDITION_DEFINITION_NAME, DataTypeDefinition.QNAME, true,
            getParamDisplayLabel(RenditionDefinitionImpl.RENDITION_DEFINITION_NAME)));

    paramList.add(new ParameterDefinitionImpl(PARAM_RUN_AS, DataTypeDefinition.TEXT, false,
            getParamDisplayLabel(PARAM_RUN_AS)));

    paramList.add(new ParameterDefinitionImpl(PARAM_UPDATE_RENDITIONS_ON_ANY_PROPERTY_CHANGE, DataTypeDefinition.BOOLEAN, false,
            getParamDisplayLabel(PARAM_UPDATE_RENDITIONS_ON_ANY_PROPERTY_CHANGE)));

    paramList.add(new ParameterDefinitionImpl(PARAM_RENDITION_NODETYPE, DataTypeDefinition.QNAME, false,
                getParamDisplayLabel(PARAM_RENDITION_NODETYPE)));

    paramList.add(new ParameterDefinitionImpl(PARAM_PLACEHOLDER_RESOURCE_PATH, DataTypeDefinition.TEXT, false,
                getParamDisplayLabel(PARAM_PLACEHOLDER_RESOURCE_PATH)));

    paramList.add(new ParameterDefinitionImpl(PARAM_SOURCE_CONTENT_PROPERTY, DataTypeDefinition.QNAME, false,
                getParamDisplayLabel(PARAM_SOURCE_CONTENT_PROPERTY)));

    paramList.add(new ParameterDefinitionImpl(PARAM_TARGET_CONTENT_PROPERTY, DataTypeDefinition.QNAME, false,
                getParamDisplayLabel(PARAM_TARGET_CONTENT_PROPERTY)));

    paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_PATH_TEMPLATE, DataTypeDefinition.TEXT, false,
                getParamDisplayLabel(PARAM_DESTINATION_PATH_TEMPLATE)));

    paramList.add(new ParameterDefinitionImpl(PARAM_ORPHAN_EXISTING_RENDITION, DataTypeDefinition.BOOLEAN, false,
            getParamDisplayLabel(PARAM_ORPHAN_EXISTING_RENDITION)));

    paramList.add(new ParameterDefinitionImpl(PARAM_RESULT, DataTypeDefinition.CHILD_ASSOC_REF, false,
            getParamDisplayLabel(PARAM_RESULT)));

    paramList.add(new ParameterDefinitionImpl(PARAM_IS_COMPONENT_RENDITION, DataTypeDefinition.BOOLEAN, false,
            getParamDisplayLabel(PARAM_IS_COMPONENT_RENDITION)));
    return paramList;
}
 
Example 27
Project: alfresco-repository   File: CancelWorkflowActionExecuter.java   View source code 5 votes vote down vote up
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
    paramList.add(
            new ParameterDefinitionImpl(PARAM_WORKFLOW_ID_LIST,
                                        DataTypeDefinition.ANY,
                                        false,
                                        getParamDisplayLabel(PARAM_WORKFLOW_ID_LIST)));
}
 
Example 28
Project: alfresco-repository   File: StartWorkflowActionExecuter.java   View source code 5 votes vote down vote up
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_WORKFLOW_NAME, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_WORKFLOW_NAME)));
    paramList.add(new ParameterDefinitionImpl(PARAM_END_START_TASK, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_END_START_TASK)));
    paramList.add(new ParameterDefinitionImpl(PARAM_START_TASK_TRANSITION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_START_TASK_TRANSITION)));
    // TODO: start task node parameter
}
 
Example 29
Project: alfresco-repository   File: RuleServiceCoverageTest.java   View source code 5 votes vote down vote up
/**
 * Create the categories used in the tests
 */
private void createTestCategories()
{
    // Create the test model
    M2Model model = M2Model.createModel("test:rulecategory");
    model.createNamespace(TEST_NAMESPACE, "test");
    model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, "d");
    model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
    
    // Create the region category
    regionCategorisationQName = QName.createQName(TEST_NAMESPACE, "region");
    M2Aspect generalCategorisation = model.createAspect("test:" + regionCategorisationQName.getLocalName());
    generalCategorisation.setParentName("cm:" + ContentModel.ASPECT_CLASSIFIABLE.getLocalName());
    M2Property genCatProp = generalCategorisation.createProperty("test:region");
    genCatProp.setIndexed(true);
    genCatProp.setIndexedAtomically(true);
    genCatProp.setMandatory(true);
    genCatProp.setMultiValued(true);
    genCatProp.setStoredInIndex(true);
    genCatProp.setIndexTokenisationMode(IndexTokenisationMode.TRUE);
    genCatProp.setType("d:" + DataTypeDefinition.CATEGORY.getLocalName());        

    // Save the mode
    dictionaryDAO.putModel(model);
    
    // Create the category value container and root
    catContainer = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(TEST_NAMESPACE, "categoryContainer"), ContentModel.TYPE_CONTAINER).getChildRef();
    catRoot = nodeService.createNode(catContainer, ContentModel.ASSOC_CHILDREN, QName.createQName(TEST_NAMESPACE, "categoryRoot"), ContentModel.TYPE_CATEGORYROOT).getChildRef();

    // Create the category values
    catRBase = nodeService.createNode(catRoot, ContentModel.ASSOC_CATEGORIES, QName.createQName(TEST_NAMESPACE, "region"), ContentModel.TYPE_CATEGORY).getChildRef();
    catROne = nodeService.createNode(catRBase, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(TEST_NAMESPACE, "Europe"), ContentModel.TYPE_CATEGORY).getChildRef();
    catRTwo = nodeService.createNode(catRBase, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(TEST_NAMESPACE, "RestOfWorld"), ContentModel.TYPE_CATEGORY).getChildRef();
    catRThree = nodeService.createNode(catRTwo, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(TEST_NAMESPACE, "US"), ContentModel.TYPE_CATEGORY).getChildRef();
}
 
Example 30
Project: alfresco-repository   File: ScriptAction.java   View source code 5 votes vote down vote up
/**
 * Convert Action Parameter for Script usage
 * 
 * @param paramName
 *            parameter name
 * @param value
 *            value to convert
 * @return converted value
 */
@SuppressWarnings("synthetic-access")
public Serializable convertActionParamForScript(String paramName, Serializable value)
{
    ParameterDefinition paramDef = actionDef.getParameterDefintion(paramName);
    if (paramDef != null && paramDef.getType().equals(DataTypeDefinition.QNAME))
    {
        return ((QName) value).toPrefixString(namespaceService);
    }
    else
    {
        return convertValueForScript(services, scope, null, value);
    }
}
 
Example 31
Project: alfresco-repository   File: WorkflowFormProcessorTest.java   View source code 5 votes vote down vote up
private Map<QName, PropertyDefinition> makeTaskPropertyDefs()
{
    Map<QName, PropertyDefinition> properties = new HashMap<QName, PropertyDefinition>();
    QName intType = DataTypeDefinition.INT;
    MockClassAttributeDefinition priorityDef = MockClassAttributeDefinition.mockPropertyDefinition(PRIORITY_NAME, intType, "2");
    properties.put(PRIORITY_NAME, priorityDef);
    
    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,
                "add_package_item_actions");
    properties.put(pckgActionGroup, pckgAction);

    // Add a Package Action property
    QName pckgItemActionGroup = PROP_PACKAGE_ITEM_ACTION_GROUP;
    PropertyDefinition pckgItemAction = MockClassAttributeDefinition.mockPropertyDefinition(pckgItemActionGroup,
                textType, "start_package_item_actions");
    properties.put(pckgItemActionGroup, pckgItemAction);

    return properties;
}
 
Example 32
Project: alfresco-repository   File: SOLRTrackingComponentImpl.java   View source code 5 votes vote down vote up
/**
    * {@inheritDoc}
    */
public void getNodes(NodeParameters nodeParameters, NodeQueryCallback callback)
{
    if(enabled)
    {
        QName shardPropertQName = null;
        if(nodeParameters.getShardProperty() != null)
        {
            PropertyDefinition pdef = QueryParserUtils.matchPropertyDefinition(NamespaceService.CONTENT_MODEL_1_0_URI, namespaceService, dictionaryService, nodeParameters.getShardProperty());
            if(pdef == null)
            {
                throw new AlfrescoRuntimeException("Invalid shard property: "+nodeParameters.getShardProperty());
            }
            if((!pdef.getDataType().getName().equals(DataTypeDefinition.TEXT)) && (!pdef.getDataType().getName().equals(DataTypeDefinition.DATE))  && (!pdef.getDataType().getName().equals(DataTypeDefinition.DATETIME)))
            {
                throw new AlfrescoRuntimeException("Unsupported shard property type: "+(pdef.getDataType().getName() + " for " +nodeParameters.getShardProperty()));
            }
            shardPropertQName = pdef.getName();
        }
        
        List<Node> nodes = solrDAO.getNodes(nodeParameters, shardPropertQName);

        for (Node node : nodes)
        {
            callback.handleNode(node);
        }
    }
}
 
Example 33
Project: alfresco-repository   File: AbstractNodeServiceImpl.java   View source code 5 votes vote down vote up
/**
 * Sets the default property values
 * 
 * @param classDefinition       the model type definition for which to get defaults
 */
protected Map<QName, Serializable> getDefaultProperties(ClassDefinition classDefinition)
{
    PropertyMap properties = new PropertyMap();
    for (Map.Entry<QName, Serializable> entry : classDefinition.getDefaultValues().entrySet())
    {
        Serializable value = entry.getValue();
        
        // Check the type of the default property
        PropertyDefinition prop = this.dictionaryService.getProperty(entry.getKey());
        if (prop == null)
        {
            // dictionary doesn't have a default value present
            continue;
        }

        // TODO: what other conversions are necessary here for other types of default values ?
        
        // ensure that we deliver the property in the correct form
        if (DataTypeDefinition.BOOLEAN.equals(prop.getDataType().getName()) == true)
        {
            if (value instanceof String)
            {
                if (((String)value).toUpperCase().equals("TRUE") == true)
                {
                    value = Boolean.TRUE;
                }
                else if (((String)value).toUpperCase().equals("FALSE") == true)
                {
                    value = Boolean.FALSE;
                }
            }
        }
        
        // Set the default value of the property
        properties.put(entry.getKey(), value);
    }
    return properties;
}
 
Example 34
Project: alfresco-repository   File: ComparePropertyValueEvaluator.java   View source code 5 votes vote down vote up
/**
 * Add parameter definitions
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_PROPERTY)));
    paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_PROPERTY, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_CONTENT_PROPERTY), false, "ac-content-properties"));
    paramList.add(new ParameterDefinitionImpl(PARAM_VALUE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_VALUE)));
    paramList.add(new ParameterDefinitionImpl(PARAM_OPERATION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_OPERATION), false, "ac-compare-operations"));
}
 
Example 35
Project: alfresco-repository   File: CompareMimeTypeEvaluator.java   View source code 5 votes vote down vote up
/**
 * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_PROPERTY)));
    paramList.add(new ParameterDefinitionImpl(PARAM_VALUE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_VALUE), false, "ac-mimetypes"));                
}
 
Example 36
Project: alfresco-repository   File: InCategoryEvaluator.java   View source code 5 votes vote down vote up
/**
 * Add the parameter definitions
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_CATEGORY_ASPECT, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_CATEGORY_ASPECT)));
    paramList.add(new ParameterDefinitionImpl(PARAM_CATEGORY_VALUE, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_CATEGORY_VALUE)));
}
 
Example 37
Project: alfresco-repository   File: SolrQueryHTTPClientTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
    Map<String, String> languageMappings = new HashMap<String, String>();
    languageMappings.put("solr-alfresco", "alfresco");
    languageMappings.put("solr-fts-alfresco", "afts");
    languageMappings.put("solr-cmis", "cmis");

    NamespaceDAO namespaceDAO = mock(NamespaceDAO.class);
    DictionaryService dictionaryService = mock(DictionaryService.class);

    when(namespaceDAO.getPrefixes()).thenReturn(Arrays.asList(CONTENT_MODEL_PREFIX, "exif"));
    when(namespaceDAO.getNamespaceURI(anyString())).thenReturn(NamespaceService.CONTENT_MODEL_1_0_URI);

    when(dictionaryService.getProperty(notNull(QName.class))).thenAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        QName qName = (QName) args[0];
        if (qName.getLocalName().contains("created"))
        {
            return MockClassAttributeDefinition.mockPropertyDefinition(qName, DataTypeDefinition.DATE);
        }
        else
        {
            return MockClassAttributeDefinition.mockPropertyDefinition(qName, DataTypeDefinition.ANY);
        }

    });

    client.setLanguageMappings(languageMappings);
    client.setDictionaryService(dictionaryService);
    client.setNamespaceDAO(namespaceDAO);

    //required for init() but not used.
    client.setNodeService(mock(NodeService.class));
    client.setTenantService(mock(TenantService.class));
    client.setPermissionService(mock(PermissionService.class));
    client.setStoreMappings(Collections.emptyList());
    client.setRepositoryState(mock(RepositoryState.class));
    client.init();
}
 
Example 38
Project: alfresco-repository   File: MailActionExecuter.java   View source code 5 votes vote down vote up
/**
 * Add the parameter definitions
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_TO, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_TO)));
    paramList.add(new ParameterDefinitionImpl(PARAM_CC, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_CC)));
    paramList.add(new ParameterDefinitionImpl(PARAM_BCC, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_BCC)));
    paramList.add(new ParameterDefinitionImpl(PARAM_TO_MANY, DataTypeDefinition.ANY, false, getParamDisplayLabel(PARAM_TO_MANY), true));
    paramList.add(new ParameterDefinitionImpl(PARAM_SUBJECT, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_SUBJECT)));
    paramList.add(new ParameterDefinitionImpl(PARAM_TEXT, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_TEXT)));
    paramList.add(new ParameterDefinitionImpl(PARAM_FROM, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_FROM)));
    paramList.add(new ParameterDefinitionImpl(PARAM_TEMPLATE, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_TEMPLATE), false, "ac-email-templates"));
    paramList.add(new ParameterDefinitionImpl(PARAM_TEMPLATE_MODEL, DataTypeDefinition.ANY, false, getParamDisplayLabel(PARAM_TEMPLATE_MODEL), true));
    paramList.add(new ParameterDefinitionImpl(PARAM_IGNORE_SEND_FAILURE, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_IGNORE_SEND_FAILURE)));
}
 
Example 39
Project: alfresco-repository   File: SetPropertyValueActionExecuter.java   View source code 5 votes vote down vote up
/**
 * Add parameter definitions
 */
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) 
{
    paramList.add(new ParameterDefinitionImpl(PARAM_PROPERTY, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_PROPERTY), false, "ac-properties"));
    paramList.add(new ParameterDefinitionImpl(PARAM_VALUE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_VALUE)));
}
 
Example 40
Project: alfresco-repository   File: ScriptActionExecuter.java   View source code 5 votes vote down vote up
/**
 * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
 */
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
    if (scriptLocation == null)
    {
        paramList.add(new ParameterDefinitionImpl(PARAM_SCRIPTREF, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_SCRIPTREF), false, "ac-scripts"));
    }
}