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

The following examples show how to use org.alfresco.service.cmr.dictionary.DataTypeDefinition#NODE_REF . 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: BaseTemplateRenderingEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Collection<ParameterDefinition> getParameterDefinitions()
{
    Collection<ParameterDefinition> paramList = super.getParameterDefinitions();
    ParameterDefinitionImpl modelParamDef = new ParameterDefinitionImpl(PARAM_MODEL, DataTypeDefinition.ANY, false,
            getParamDisplayLabel(PARAM_MODEL));
    ParameterDefinitionImpl templateParamDef = new ParameterDefinitionImpl(//
            PARAM_TEMPLATE, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_TEMPLATE));
    ParameterDefinitionImpl templateNodeParamDef = new ParameterDefinitionImpl(PARAM_TEMPLATE_NODE,
            DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_TEMPLATE_NODE));
    ParameterDefinitionImpl templatePathParamDef = new ParameterDefinitionImpl(PARAM_TEMPLATE_PATH,
            DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_TEMPLATE_PATH));
    paramList.add(new ParameterDefinitionImpl(PARAM_MIME_TYPE, DataTypeDefinition.TEXT, false,
            getParamDisplayLabel(PARAM_MIME_TYPE)));
    paramList.add(modelParamDef);
    paramList.add(templateParamDef);
    paramList.add(templateNodeParamDef);
    paramList.add(templatePathParamDef);
    return paramList;
}
 
Example 2
Source File: RestVariableHelper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public QName extractTypeFromValue(Object value) {
    QName type = null;
    if(value instanceof Collection<?>)
    {
        Collection<?> collection = (Collection<?>) value;
        if(collection.size() > 0)
        {
            type = extractTypeFromValue(collection.iterator().next());
        }
    }
    else
    {
        if(value instanceof String) 
        {
            type = DataTypeDefinition.TEXT;
        }
        else if(value instanceof Integer)
        {
            type = DataTypeDefinition.INT;
        }
        else if(value instanceof Long)
        {
            type = DataTypeDefinition.LONG;
        }
        else if(value instanceof Double)
        {
            type = DataTypeDefinition.DOUBLE;
        }
        else if(value instanceof Float)
        {
            type = DataTypeDefinition.FLOAT;
        }
        else if(value instanceof Date)
        {
            type = DataTypeDefinition.DATETIME;
        }
        else if(value instanceof Boolean)
        {
            type = DataTypeDefinition.BOOLEAN;
        }
        else if(value instanceof QName)
        {
            type = DataTypeDefinition.QNAME;
        }
        else if(value instanceof NodeRef || value instanceof ScriptNode)
        {
            type = DataTypeDefinition.NODE_REF;
        }
    }
   
    if(type == null)
    {
        // Type cannot be determined, revert to default for unknown types
        type = DataTypeDefinition.ANY;
    }
    return type;
}