Java Code Examples for org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl#addProperty()

The following examples show how to use org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl#addProperty() . 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: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a properties object
 * 
 * @param properties the object to convert
 * 
 * @return the converted properties object
 */
public static Properties convert(CmisPropertiesType properties) {
	if (properties == null) {
		return null;
	}

	PropertiesImpl result = new PropertiesImpl();

	for (CmisProperty property : properties.getProperty()) {
		result.addProperty(convert(property));
	}

	// handle extensions
	convertExtension(properties, result);

	return result;
}
 
Example 2
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Properties getAssocProperties(CMISNodeInfo info, String filter)
{
    PropertiesImpl result = new PropertiesImpl();

    Set<String> filterSet = splitFilter(filter);

    for (PropertyDefinitionWrapper propDefWrap : info.getType().getProperties())
    {
        PropertyDefinition<?> propDef = propDefWrap.getPropertyDefinition();
        if ((filterSet != null) && (!filterSet.contains(propDef.getQueryName())))
        {
            // skip properties that are not in the filter
            continue;
        }

        CMISPropertyAccessor cmisPropertyAccessor = propDefWrap.getPropertyAccessor();
        Serializable value = cmisPropertyAccessor.getValue(info);
        PropertyType propType = propDef.getPropertyType();
        PropertyData<?> propertyData = getProperty(propType, propDefWrap, value);
        result.addProperty(propertyData);
    }

    return result;
}
 
Example 3
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Properties getNodeProperties(CMISNodeInfo info, String filter)
{
    PropertiesImpl result = new PropertiesImpl();

    Set<String> filterSet = splitFilter(filter);

    for (PropertyDefinitionWrapper propDef : info.getType().getProperties())
    {
        if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID))
        {
            // don't filter the object id
            if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
            {
                // skip properties that are not in the filter
                continue;
            }
        }

        Serializable value = propDef.getPropertyAccessor().getValue(info);
        result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
    }

    addAspectProperties(info, filter, result);

    return result;
}
 
Example 4
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addPropertyId(PropertiesImpl props, String typeId, Set<String> filter, String id, String value) {
	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}

	PropertyIdImpl p = new PropertyIdImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example 5
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void addPropertyDateTime(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, GregorianCalendar value) {
	if (!checkAddProperty(props, type, filter, id)) {
		return;
	}

	props.addProperty(new PropertyDateTimeImpl(id, value));
}
 
Example 6
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void addPropertyBoolean(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, boolean value) {
	if (!checkAddProperty(props, type, filter, id)) {
		return;
	}

	props.addProperty(new PropertyBooleanImpl(id, value));
}
 
Example 7
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void addPropertyBigInteger(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, BigInteger value) {
	if (!checkAddProperty(props, type, filter, id)) {
		return;
	}

	props.addProperty(new PropertyIntegerImpl(id, value));
}
 
Example 8
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void addPropertyString(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, String value) {
	if (!checkAddProperty(props, type, filter, id)) {
		return;
	}

	props.addProperty(new PropertyStringImpl(id, value));
}
 
Example 9
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
static void addPropertyId(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, String value) {
	if (!checkAddProperty(props, type, filter, id)) {
		return;
	}

	props.addProperty(new PropertyIdImpl(id, value));
}
 
Example 10
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addAspectProperties(CMISNodeInfo info, String filter, PropertiesImpl result)
{
    if (getRequestCmisVersion().equals(CmisVersion.CMIS_1_1))
    {
        Set<String> propertyIds = new HashSet<>();
        Set<String> filterSet = splitFilter(filter);

        Set<QName> aspects = info.getNodeAspects();
        for (QName aspect : aspects)
        {
            TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect);
            if (aspectType == null)
            {
                continue;
            }

            for (PropertyDefinitionWrapper propDef : aspectType.getProperties())
            {
                if (propertyIds.contains(propDef.getPropertyId()))
                {
                    // skip properties that have already been added
                    continue;
                }

                if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
                {
                    // skip properties that are not in the filter
                    continue;
                }

                Serializable value = propDef.getPropertyAccessor().getValue(info);
                result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));

                // mark property as 'added'
                propertyIds.add(propDef.getPropertyId());
            }
        }
    }
}
 
Example 11
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addPropertyDateTime(PropertiesImpl props, String typeId, Set<String> filter, String id,
		GregorianCalendar value) {

	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}

	PropertyDateTimeImpl p = new PropertyDateTimeImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example 12
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addPropertyBoolean(PropertiesImpl props, String typeId, Set<String> filter, String id, boolean value) {
	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}

	PropertyBooleanImpl p = new PropertyBooleanImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example 13
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addPropertyBigInteger(PropertiesImpl props, String typeId, Set<String> filter, String id,
		BigInteger value) {
	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}

	PropertyIntegerImpl p = new PropertyIntegerImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example 14
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addPropertyString(PropertiesImpl props, String typeId, Set<String> filter, String id, String value) {
	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}
	PropertyStringImpl p = new PropertyStringImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example 15
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addPropertyIdList(PropertiesImpl props, String typeId, Set<String> filter, String id,
		List<String> value) {
	if (!checkAddProperty(props, typeId, filter, id)) {
		return;
	}

	PropertyIdImpl p = new PropertyIdImpl(id, value);
	p.setQueryName(id);
	props.addProperty(p);
}
 
Example 16
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public List<ObjectData> getFolderLastChanges(long minDate, int max) {
	
	StringBuffer query = new StringBuffer(" _entity.tenantId=?1 and _entity.date >= ?2 ");
	query.append(" and _entity.event in ('");
	query.append(FolderEvent.CREATED);
	query.append("','");
	query.append(FolderEvent.RENAMED);
	query.append("','");
	query.append(FolderEvent.MOVED);
	query.append("','");		
	query.append(FolderEvent.DELETED);
	query.append("')");

	List<FolderHistory> entries = new ArrayList<FolderHistory>();

	try {
		entries = folderHistoryDao.findByWhere(query.toString(),
				new Object[] { getRoot().getTenantId(), new Date(minDate) }, "order by _entity.date", max);
	} catch (PersistenceException e) {
		log.error(e.getMessage(), e);
	}

	List<ObjectData> ods = new ArrayList<ObjectData>(entries.size());
	Date date = null;
	for (FolderHistory logEntry : entries) {
		ObjectDataImpl od = new ObjectDataImpl();
		ChangeEventInfoDataImpl cei = new ChangeEventInfoDataImpl();
		
		// change type
		String eventId = logEntry.getEvent();
		ChangeType changeType;
		if (FolderEvent.CREATED.toString().equals(eventId)) {
			changeType = ChangeType.CREATED;
		} else if (FolderEvent.RENAMED.toString().equals(eventId) || FolderEvent.MOVED.toString().equals(eventId) ) {
			changeType = ChangeType.UPDATED;
		} else if (FolderEvent.DELETED.toString().equals(eventId)) {
			changeType = ChangeType.DELETED;
		} else {
			continue;
		}
		cei.setChangeType(changeType);
		
		// change time
		GregorianCalendar changeTime = (GregorianCalendar) Calendar.getInstance();
		date = logEntry.getDate();
		changeTime.setTime(date);
		cei.setChangeTime(changeTime);
		od.setChangeEventInfo(cei);
		
		// properties: id, doc type
		PropertiesImpl properties = new PropertiesImpl();
		properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_ID, ID_PREFIX_FLD + logEntry.getFolderId()));
		properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_FOLDER.value()));
		od.setProperties(properties);
		ods.add(od);
	}
	return ods;
}
 
Example 17
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public List<ObjectData> getDocumentLastChanges(long minDate, int max) {
	
	StringBuffer query = new StringBuffer(" _entity.tenantId=?1 and _entity.date >= ?2 ");
	query.append(" and _entity.event in ('");
	query.append(DocumentEvent.STORED);
	query.append("','");
	query.append(DocumentEvent.CHECKEDIN);
	query.append("','");
	query.append(DocumentEvent.MOVED);
	query.append("','");		
	query.append(DocumentEvent.RENAMED);
	query.append("','");
	query.append(DocumentEvent.DELETED);
	query.append("')");

	List<DocumentHistory> entries = new ArrayList<DocumentHistory>();

	try {
		entries = historyDao.findByWhere(query.toString(),
				new Object[] { getRoot().getTenantId(), new Date(minDate) }, "order by _entity.date", max);
	} catch (PersistenceException e) {
		log.error(e.getMessage(), e);
	}

	List<ObjectData> ods = new ArrayList<ObjectData>(entries.size());
	Date date = null;
	for (DocumentHistory logEntry : entries) {
		ObjectDataImpl od = new ObjectDataImpl();
		ChangeEventInfoDataImpl cei = new ChangeEventInfoDataImpl();
		
		// change type
		String eventId = logEntry.getEvent();
		ChangeType changeType;
		if (DocumentEvent.STORED.toString().equals(eventId)) {
			changeType = ChangeType.CREATED;
		} else if (DocumentEvent.CHECKEDIN.toString().equals(eventId)
				|| DocumentEvent.RENAMED.toString().equals(eventId)
				|| DocumentEvent.MOVED.toString().equals(eventId)) {
			changeType = ChangeType.UPDATED;
		} else if (DocumentEvent.DELETED.toString().equals(eventId)) {
			changeType = ChangeType.DELETED;
		} else {
			continue;
		}
		cei.setChangeType(changeType);
		
		// change time
		GregorianCalendar changeTime = (GregorianCalendar) Calendar.getInstance();
		date = logEntry.getDate();
		changeTime.setTime(date);
		cei.setChangeTime(changeTime);
		od.setChangeEventInfo(cei);
		
		// properties: id, doc type
		PropertiesImpl properties = new PropertiesImpl();
		properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_ID, ID_PREFIX_DOC + logEntry.getDocId()));
		properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value()));
		od.setProperties(properties);
		ods.add(od);
	}
	return ods;
}
 
Example 18
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Adds the default value of property if defined.
 */
@SuppressWarnings("unchecked")
private static boolean addPropertyDefault(PropertiesImpl props, PropertyDefinition<?> propDef) {
	if ((props == null) || (props.getProperties() == null)) {
		throw new IllegalArgumentException("Props must not be null!");
	}

	if (propDef == null) {
		return false;
	}

	List<?> defaultValue = propDef.getDefaultValue();
	if ((defaultValue != null) && (!defaultValue.isEmpty())) {
		switch (propDef.getPropertyType()) {
		case BOOLEAN:
			PropertyBooleanImpl p = new PropertyBooleanImpl(propDef.getId(), (List<Boolean>) defaultValue);
			p.setQueryName(propDef.getId());
			props.addProperty(p);
			break;
		case DATETIME:
			PropertyDateTimeImpl p1 = new PropertyDateTimeImpl(propDef.getId(),
					(List<GregorianCalendar>) defaultValue);
			p1.setQueryName(propDef.getId());
			props.addProperty(p1);
			break;
		case DECIMAL:
			PropertyDecimalImpl p3 = new PropertyDecimalImpl(propDef.getId(), (List<BigDecimal>) defaultValue);
			p3.setQueryName(propDef.getId());
			props.addProperty(p3);
			break;
		case HTML:
			PropertyHtmlImpl p4 = new PropertyHtmlImpl(propDef.getId(), (List<String>) defaultValue);
			p4.setQueryName(propDef.getId());
			props.addProperty(p4);
			break;
		case ID:
			PropertyIdImpl p5 = new PropertyIdImpl(propDef.getId(), (List<String>) defaultValue);
			p5.setQueryName(propDef.getId());
			props.addProperty(p5);
			break;
		case INTEGER:
			PropertyIntegerImpl p6 = new PropertyIntegerImpl(propDef.getId(), (List<BigInteger>) defaultValue);
			p6.setQueryName(propDef.getId());
			props.addProperty(p6);
			break;
		case STRING:
			PropertyStringImpl p7 = new PropertyStringImpl(propDef.getId(), (List<String>) defaultValue);
			p7.setQueryName(propDef.getId());
			props.addProperty(p7);
			break;
		case URI:
			PropertyUriImpl p8 = new PropertyUriImpl(propDef.getId(), (List<String>) defaultValue);
			p8.setQueryName(propDef.getId());
			props.addProperty(p8);
			break;
		default:
			throw new RuntimeException("Unknown datatype! Spec change?");
		}

		return true;
	}

	return false;
}
 
Example 19
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private List<ObjectData> createChangeEvents(long time, Map<String, Serializable> values)
{
    List<ObjectData> result = new ArrayList<ObjectData>();

    if ((values == null) || (values.size() == 0))
    {
        return result;
    }

    GregorianCalendar changeTime = new GregorianCalendar();
    changeTime.setTimeInMillis(time);

    String appPath = "/" + CMIS_CHANGELOG_AUDIT_APPLICATION + "/";

    for (Entry<String, Serializable> entry : values.entrySet())
    {
        if ((entry.getKey() == null) || (!(entry.getValue() instanceof Map)))
        {
            continue;
        }

        String path = entry.getKey();
        if (!path.startsWith(appPath))
        {
            continue;
        }

        ChangeType changeType = null;
        String changePath = path.substring(appPath.length()).toLowerCase();
        for (ChangeType c : ChangeType.values())
        {
            if (changePath.startsWith(c.value().toLowerCase()))
            {
                changeType = c;
                break;
            }
        }

        if (changeType == null)
        {
            continue;
        }

        Map<String, Serializable> valueMap = (Map<String, Serializable>) entry.getValue();
        String objectId = (String) valueMap.get(CMISChangeLogDataExtractor.KEY_OBJECT_ID);

        // build object
        ObjectDataImpl object = new ObjectDataImpl();
        result.add(object);

        PropertiesImpl properties = new PropertiesImpl();
        object.setProperties(properties);
        PropertyIdImpl objectIdProperty = new PropertyIdImpl(PropertyIds.OBJECT_ID, objectId);
        properties.addProperty(objectIdProperty);

        ChangeEventInfoDataImpl changeEvent = new ChangeEventInfoDataImpl();
        object.setChangeEventInfo(changeEvent);
        changeEvent.setChangeType(changeType);
        changeEvent.setChangeTime(changeTime);
    }

    return result;
}