Java Code Examples for org.alfresco.service.cmr.dictionary.PropertyDefinition#getTitle()

The following examples show how to use org.alfresco.service.cmr.dictionary.PropertyDefinition#getTitle() . 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: Site.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get a map of the sites custom properties
 * 
 * @return map of names and values
 */
public ScriptableQNameMap<String, CustomProperty> getCustomProperties()
{
    if (this.customProperties == null)
    {
        // create the custom properties map
        ScriptNode siteNode = new ScriptNode(this.siteInfo.getNodeRef(), this.serviceRegistry);
        // set the scope, for use when converting props to javascript objects
        siteNode.setScope(scope);
        this.customProperties = new ContentAwareScriptableQNameMap<String, CustomProperty>(siteNode, this.serviceRegistry);
        
        Map<QName, Serializable> props = siteInfo.getCustomProperties();
        for (QName qname : props.keySet())
        {
            // get the property value
            Serializable propValue = props.get(qname);
            
            // convert the value
            NodeValueConverter valueConverter = siteNode.new NodeValueConverter();
            Serializable value = valueConverter.convertValueForScript(qname, propValue);
            
            // get the type and label information from the dictionary
            String title = null;
            String type = null;
            PropertyDefinition propDef = this.serviceRegistry.getDictionaryService().getProperty(qname);
            if (propDef != null)
            {
                type = propDef.getDataType().getName().toString();
                title = propDef.getTitle(this.serviceRegistry.getDictionaryService());
            }
            
            // create the custom property and add to the map
            CustomProperty customProp = new CustomProperty(qname.toString(), value, type, title);
            this.customProperties.put(qname.toString(), customProp);
        }
    }
    return this.customProperties;
}
 
Example 2
Source File: PropertyParameterConstraint.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
 */
protected Map<String, String> getAllowableValuesImpl()
{   
    Collection<QName> properties = dictionaryService.getAllProperties(null);
    Map<String, String> result = new LinkedHashMap<String, String>(properties.size());
    for (QName property : properties)
    {
        PropertyDefinition propertyDef = dictionaryService.getProperty(property);
        if (propertyDef != null && propertyDef.getTitle(dictionaryService) != null)
        {
            result.put(property.toPrefixString(), propertyDef.getTitle(dictionaryService));
        }
    }        
    return result;
}
 
Example 3
Source File: DictionaryComparators.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public int compare(PropertyDefinition arg0, PropertyDefinition arg1)
{
    int result = 0;
    
    String title0 = arg0.getTitle(messageLookup);
    if (title0 == null)
    {
        title0 = arg0.getName().toPrefixString();
    }
    String title1 = arg1.getTitle(messageLookup);
    if (title1 == null)
    {
        title1 = arg1.getName().getPrefixString();
    }
    
    if (title0 == null && title1 != null)
    {
        result = 1;
    }
    else if (title0 != null && title1 == null)
    {
        result = -1;
    }
    else if (title0 != null && title1 != null)
    {
        result = String.CASE_INSENSITIVE_ORDER.compare(title0, title1);
    }
    
    return result;
}
 
Example 4
Source File: CustomModelProperty.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public CustomModelProperty(PropertyDefinition propertyDefinition, MessageLookup messageLookup)
{
    this.name = propertyDefinition.getName().getLocalName();
    this.prefixedName = propertyDefinition.getName().toPrefixString();
    this.title = propertyDefinition.getTitle(messageLookup);
    this.dataType = propertyDefinition.getDataType().getName().toPrefixString();
    this.description = propertyDefinition.getDescription(messageLookup);
    this.isMandatory = propertyDefinition.isMandatory();
    this.isMandatoryEnforced = propertyDefinition.isMandatoryEnforced();
    this.isMultiValued = propertyDefinition.isMultiValued();
    this.defaultValue = propertyDefinition.getDefaultValue();
    this.isIndexed = propertyDefinition.isIndexed();
    this.facetable = propertyDefinition.getFacetable();
    this.indexTokenisationMode = propertyDefinition.getIndexTokenisationMode();
    List<ConstraintDefinition> constraintDefs = propertyDefinition.getConstraints();
    if (constraintDefs.size() > 0)
    {
        this.constraintRefs = new ArrayList<>();
        this.constraints = new ArrayList<>();
        for (ConstraintDefinition cd : constraintDefs)
        {
            if (cd.getRef() != null)
            {
                constraintRefs.add(cd.getRef().toPrefixString());
            }
            else
            {
                constraints.add(new CustomModelConstraint(cd, messageLookup));
            }
        }
    }
}
 
Example 5
Source File: FacetablePropertiesGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** This method returns a {@link FacetablePropertyFTL} for the specified {@link PropertyDefinition}. */
private FacetablePropertyFTL<?> toFacetablePropertyModel(PropertyDefinition propDef, Locale locale)
{
    String title = propDef.getTitle(messageLookup, locale);
    return new StandardFacetablePropertyFTL(propDef, title);
}
 
Example 6
Source File: UserCSVUploadPost.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Builds user objects based on the supplied data. If a row is empty, then
 *  the child String array should be empty too. (Needs to be present so that
 *  the line number reporting works)
 */
private void processSpreadsheetUpload(String[][] data, List<Map<QName,String>> users)
{
    // What we consider to be the literal string "user name" when detecting
    //  if a row is an example/header one or not
    // Note - all of these want to be lower case!
    List<String> usernameIsUsername = new ArrayList<String>();
    // The English literals
    usernameIsUsername.add("username");
    usernameIsUsername.add("user name");
    // And the localised form too if found
    PropertyDefinition unPD = dictionaryService.getProperty(ContentModel.PROP_USERNAME);
    if (unPD != null)
    {
        if(unPD.getTitle(dictionaryService) != null)
            usernameIsUsername.add(unPD.getTitle(dictionaryService).toLowerCase());
        if(unPD.getDescription(dictionaryService) != null)
            usernameIsUsername.add(unPD.getDescription(dictionaryService).toLowerCase());
    }
    
    
    // Process the contents of the spreadsheet
    for (int lineNumber=0; lineNumber<data.length; lineNumber++)
    {
        Map<QName,String> user = new HashMap<QName, String>();
        String[] userData = data[lineNumber];
        
        if (userData == null || userData.length == 0 || 
           (userData.length == 1 && userData[0].trim().length() == 0))
        {
            // Empty line, skip
            continue;
        }
        
        boolean required = true;
        for (int i=0; i<COLUMNS.length; i++)
        {
            if (COLUMNS[i] == null)
            {
                required = false;
                continue;
            }
            
            String value = null;
            if (userData.length > i)
            {
                value = userData[i];
            }
            if (value == null || value.length() == 0)
            {
                if (required)
                {
                    throw new ResourceBundleWebScriptException(
                            Status.STATUS_OK, getResources(),
                            ERROR_BLANK_COLUMN, new Object[] {
                                    COLUMNS[i].getLocalName(), (i+1), (lineNumber+1)});
                }
            }
            else
            {
                user.put(COLUMNS[i], value);
            }
        }

        // If no password was given, use their surname
        if (!user.containsKey(ContentModel.PROP_PASSWORD))
        {
            user.put(ContentModel.PROP_PASSWORD, "");
        }
        
        // Skip any user who looks like an example file heading
        // i.e. a username of "username" or "user name"
        String username = user.get(ContentModel.PROP_USERNAME).toLowerCase();
        if (usernameIsUsername.contains(username))
        {
            // Skip
        }
        else
        {
            // Looks like a real line, keep it
            users.add(user);
        }
    }
}