Search in sources :

Example 1 with PropertyString

use of org.apache.chemistry.opencmis.commons.data.PropertyString in project iaf by ibissource.

the class CmisUtils method getPropertyXml.

public static XmlBuilder getPropertyXml(PropertyData<?> property) {
    XmlBuilder propertyXml = new XmlBuilder("property");
    propertyXml.addAttribute("name", property.getId());
    propertyXml.addAttribute("displayName", property.getDisplayName());
    propertyXml.addAttribute("localName", property.getLocalName());
    propertyXml.addAttribute("queryName", property.getQueryName());
    PropertyType propertyType = PropertyType.STRING;
    if (property instanceof Property) {
        propertyType = ((Property<?>) property).getType();
    } else {
        if (property instanceof PropertyId) {
            propertyType = PropertyType.ID;
        } else if (property instanceof PropertyBoolean) {
            propertyType = PropertyType.BOOLEAN;
        } else if (property instanceof PropertyUri) {
            propertyType = PropertyType.URI;
        } else if (property instanceof PropertyInteger) {
            propertyType = PropertyType.INTEGER;
        } else if (property instanceof PropertyHtml) {
            propertyType = PropertyType.HTML;
        } else if (property instanceof PropertyDecimal) {
            propertyType = PropertyType.DECIMAL;
        } else if (property instanceof PropertyString) {
            propertyType = PropertyType.STRING;
        } else if (property instanceof PropertyDateTime) {
            propertyType = PropertyType.DATETIME;
        }
    }
    // If it's not a property, what would it be? assume its a string...
    propertyXml.addAttribute("type", propertyType.value());
    Object value = property.getFirstValue();
    if (value == null) {
        propertyXml.addAttribute("isNull", "true");
    } else {
        switch(propertyType) {
            case INTEGER:
                BigInteger bi = (BigInteger) value;
                propertyXml.setValue(String.valueOf(bi));
                break;
            case BOOLEAN:
                Boolean b = (Boolean) value;
                propertyXml.setValue(String.valueOf(b));
                break;
            case DATETIME:
                GregorianCalendar gc = (GregorianCalendar) value;
                SimpleDateFormat sdf = new SimpleDateFormat(FORMATSTRING_BY_DEFAULT);
                propertyXml.setValue(sdf.format(gc.getTime()));
                break;
            default:
                // String/ID/HTML/URI
                propertyXml.setValue((String) value);
                break;
        }
    }
    return propertyXml;
}
Also used : PropertyString(org.apache.chemistry.opencmis.commons.data.PropertyString) PropertyBoolean(org.apache.chemistry.opencmis.commons.data.PropertyBoolean) PropertyUri(org.apache.chemistry.opencmis.commons.data.PropertyUri) PropertyInteger(org.apache.chemistry.opencmis.commons.data.PropertyInteger) GregorianCalendar(java.util.GregorianCalendar) PropertyType(org.apache.chemistry.opencmis.commons.enums.PropertyType) PropertyId(org.apache.chemistry.opencmis.commons.data.PropertyId) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) BigInteger(java.math.BigInteger) CmisObject(org.apache.chemistry.opencmis.client.api.CmisObject) PropertyDateTime(org.apache.chemistry.opencmis.commons.data.PropertyDateTime) PropertyBoolean(org.apache.chemistry.opencmis.commons.data.PropertyBoolean) Property(org.apache.chemistry.opencmis.client.api.Property) SimpleDateFormat(java.text.SimpleDateFormat) PropertyHtml(org.apache.chemistry.opencmis.commons.data.PropertyHtml) PropertyDecimal(org.apache.chemistry.opencmis.commons.data.PropertyDecimal)

Aggregations

BigInteger (java.math.BigInteger)1 SimpleDateFormat (java.text.SimpleDateFormat)1 GregorianCalendar (java.util.GregorianCalendar)1 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)1 CmisObject (org.apache.chemistry.opencmis.client.api.CmisObject)1 Property (org.apache.chemistry.opencmis.client.api.Property)1 PropertyBoolean (org.apache.chemistry.opencmis.commons.data.PropertyBoolean)1 PropertyDateTime (org.apache.chemistry.opencmis.commons.data.PropertyDateTime)1 PropertyDecimal (org.apache.chemistry.opencmis.commons.data.PropertyDecimal)1 PropertyHtml (org.apache.chemistry.opencmis.commons.data.PropertyHtml)1 PropertyId (org.apache.chemistry.opencmis.commons.data.PropertyId)1 PropertyInteger (org.apache.chemistry.opencmis.commons.data.PropertyInteger)1 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)1 PropertyUri (org.apache.chemistry.opencmis.commons.data.PropertyUri)1 PropertyType (org.apache.chemistry.opencmis.commons.enums.PropertyType)1