use of org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl in project copper-cms by PogeyanOSS.
the class CreateAndDeleteTypeTest method createPropertyDefinition.
private AbstractPropertyDefinition<?> createPropertyDefinition(PropertyType propertyType) {
AbstractPropertyDefinition<?> result = null;
switch(propertyType) {
case BOOLEAN:
result = new PropertyBooleanDefinitionImpl();
break;
case ID:
result = new PropertyIdDefinitionImpl();
break;
case INTEGER:
result = new PropertyIntegerDefinitionImpl();
break;
case DATETIME:
result = new PropertyDateTimeDefinitionImpl();
break;
case DECIMAL:
result = new PropertyDecimalDefinitionImpl();
break;
case HTML:
result = new PropertyHtmlDefinitionImpl();
break;
case URI:
result = new PropertyUriDefinitionImpl();
break;
default:
result = new PropertyStringDefinitionImpl();
}
result.setPropertyType(propertyType);
result.setId("tck:" + propertyType.value());
result.setLocalName("tck:local_" + propertyType.value());
result.setLocalNamespace("tck:testlocalnamespace");
result.setDisplayName("TCK " + propertyType.value() + " propertry");
result.setQueryName("tck:" + propertyType.value());
result.setDescription("TCK " + propertyType.value() + " propertry");
result.setCardinality(Cardinality.SINGLE);
result.setUpdatability(Updatability.READWRITE);
result.setIsInherited(false);
result.setIsQueryable(false);
result.setIsOrderable(false);
result.setIsRequired(false);
result.setIsOpenChoice(true);
return result;
}
use of org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl in project iaf by ibissource.
the class CmisUtils method xml2PropertyDefinition.
private static PropertyDefinition<?> xml2PropertyDefinition(Element propertyDefinitionXml) {
MutablePropertyDefinition<?> definition = null;
PropertyType type = PropertyType.fromValue(propertyDefinitionXml.getAttribute("propertyType"));
switch(type) {
case ID:
definition = new PropertyIdDefinitionImpl();
break;
case BOOLEAN:
definition = new PropertyBooleanDefinitionImpl();
break;
case DATETIME:
definition = new PropertyDateTimeDefinitionImpl();
break;
case DECIMAL:
definition = new PropertyDecimalDefinitionImpl();
break;
case INTEGER:
definition = new PropertyIntegerDefinitionImpl();
break;
case HTML:
definition = new PropertyHtmlDefinitionImpl();
break;
case URI:
definition = new PropertyUriDefinitionImpl();
break;
case STRING:
default:
definition = new PropertyStringDefinitionImpl();
break;
}
definition.setPropertyType(type);
definition.setId(propertyDefinitionXml.getAttribute("id"));
definition.setDisplayName(CmisUtils.parseStringAttr(propertyDefinitionXml, "displayName"));
definition.setDescription(CmisUtils.parseStringAttr(propertyDefinitionXml, "description"));
definition.setLocalName(CmisUtils.parseStringAttr(propertyDefinitionXml, "localName"));
definition.setLocalNamespace(CmisUtils.parseStringAttr(propertyDefinitionXml, "localNamespace"));
definition.setQueryName(CmisUtils.parseStringAttr(propertyDefinitionXml, "queryName"));
if (propertyDefinitionXml.hasAttribute("cardinality")) {
definition.setCardinality(Cardinality.valueOf(propertyDefinitionXml.getAttribute("cardinality")));
}
if (propertyDefinitionXml.hasAttribute("updatability")) {
definition.setUpdatability(Updatability.valueOf(propertyDefinitionXml.getAttribute("updatability")));
}
definition.setIsInherited(CmisUtils.parseBooleanAttr(propertyDefinitionXml, "inherited"));
definition.setIsOpenChoice(CmisUtils.parseBooleanAttr(propertyDefinitionXml, "openChoice"));
definition.setIsOrderable(CmisUtils.parseBooleanAttr(propertyDefinitionXml, "orderable"));
definition.setIsQueryable(CmisUtils.parseBooleanAttr(propertyDefinitionXml, "queryable"));
definition.setIsRequired(CmisUtils.parseBooleanAttr(propertyDefinitionXml, "required"));
if (propertyDefinitionXml.hasAttribute("defaultValue")) {
// TODO: turn this into a list
List defaultValues = new ArrayList();
String defaultValue = propertyDefinitionXml.getAttribute("defaultValue");
defaultValues.add(defaultValue);
definition.setDefaultValue(defaultValues);
}
return definition;
}
use of org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl in project iaf by ibissource.
the class CmisUtils method processProperties.
public static Properties processProperties(Element cmisElement) {
PropertiesImpl properties = new PropertiesImpl();
Element propertiesElement = XmlUtils.getFirstChildTag(cmisElement, "properties");
Iterator<Node> propertyIterator = XmlUtils.getChildTags(propertiesElement, "property").iterator();
while (propertyIterator.hasNext()) {
Element propertyElement = (Element) propertyIterator.next();
String propertyValue = XmlUtils.getStringValue(propertyElement);
String nameAttr = propertyElement.getAttribute("name");
String typeAttr = propertyElement.getAttribute("type");
PropertyType propertyType = PropertyType.STRING;
if (StringUtils.isNotEmpty(typeAttr)) {
propertyType = PropertyType.fromValue(typeAttr);
}
if (StringUtils.isEmpty(typeAttr) && nameAttr.startsWith("cmis:")) {
propertyType = PropertyType.ID;
}
boolean isNull = Boolean.parseBoolean(propertyElement.getAttribute("isNull"));
if (isNull)
propertyValue = null;
switch(propertyType) {
case ID:
properties.addProperty(new PropertyIdImpl(addStandardDefinitions(new PropertyIdDefinitionImpl(), propertyElement, propertyType), propertyValue));
break;
case STRING:
properties.addProperty(new PropertyStringImpl(addStandardDefinitions(new PropertyStringDefinitionImpl(), propertyElement, propertyType), propertyValue));
break;
case INTEGER:
BigInteger bigInt = null;
if (StringUtils.isNotEmpty(propertyValue)) {
bigInt = new BigInteger(propertyValue);
}
properties.addProperty(new PropertyIntegerImpl(addStandardDefinitions(new PropertyIntegerDefinitionImpl(), propertyElement, propertyType), bigInt));
break;
case DATETIME:
GregorianCalendar gregorian = null;
if (StringUtils.isNotEmpty(propertyValue)) {
String formatStringAttr = propertyElement.getAttribute("formatString");
String timezoneAttr = propertyElement.getAttribute("timezone");
if (StringUtils.isEmpty(formatStringAttr)) {
formatStringAttr = CmisUtils.FORMATSTRING_BY_DEFAULT;
}
DateFormat df = new SimpleDateFormat(formatStringAttr);
try {
Date date = df.parse(propertyValue);
gregorian = new GregorianCalendar();
gregorian.setTime(date);
if (StringUtils.isNotEmpty(timezoneAttr)) {
gregorian.setTimeZone(TimeZone.getTimeZone(timezoneAttr));
}
} catch (ParseException e) {
log.warn("exception parsing date [" + propertyValue + "] using formatString [" + formatStringAttr + "]", e);
}
}
properties.addProperty(new PropertyDateTimeImpl(addStandardDefinitions(new PropertyDateTimeDefinitionImpl(), propertyElement, propertyType), gregorian));
break;
case BOOLEAN:
Boolean bool = null;
if (StringUtils.isNotEmpty(propertyValue)) {
bool = Boolean.parseBoolean(propertyValue);
}
properties.addProperty(new PropertyBooleanImpl(addStandardDefinitions(new PropertyBooleanDefinitionImpl(), propertyElement, propertyType), bool));
break;
case DECIMAL:
BigDecimal decimal = null;
if (StringUtils.isNotEmpty(propertyValue)) {
decimal = new BigDecimal(propertyValue);
}
properties.addProperty(new PropertyDecimalImpl(addStandardDefinitions(new PropertyDecimalDefinitionImpl(), propertyElement, propertyType), decimal));
break;
case URI:
properties.addProperty(new PropertyUriImpl(addStandardDefinitions(new PropertyUriDefinitionImpl(), propertyElement, propertyType), propertyValue));
break;
case HTML:
properties.addProperty(new PropertyHtmlImpl(addStandardDefinitions(new PropertyHtmlDefinitionImpl(), propertyElement, propertyType), propertyValue));
break;
default:
log.warn("unparsable type [" + typeAttr + "] for property [" + propertyValue + "]");
// Skip all and continue with the next property!
continue;
}
log.debug("set property name [" + nameAttr + "] value [" + propertyValue + "]");
}
return properties;
}
Aggregations