Java Code Examples for org.alfresco.service.cmr.dictionary.PropertyDefinition#getDataType()
The following examples show how to use
org.alfresco.service.cmr.dictionary.PropertyDefinition#getDataType() .
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: AbstractWorkflowPropertyHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected Object convertPropertyValue(PropertyDefinition propDef, Serializable value) { Object newValue = value; // Convert property value using a default type converter if (value instanceof Collection<?>) { // Convert a collecion of values newValue =typeConverter.convert(propDef.getDataType(), (Collection<?>) value); } else { // Convert a single value newValue = typeConverter.convert(propDef.getDataType(), value); } // Convert NodeRefs to ActivitiScriptNodes DataTypeDefinition dataTypeDef = propDef.getDataType(); if (dataTypeDef.getName().equals(DataTypeDefinition.NODE_REF)) { newValue = nodeConverter.convertNodes(newValue, propDef.isMultiValued()); } return newValue; }
Example 2
Source File: EventGenerationBehaviours.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private DataType getPropertyType(QName propertyName) { DataType dataType = null; PropertyDefinition def = dictionaryService.getProperty(propertyName); if(def != null) { DataTypeDefinition dataTypeDef = def.getDataType(); String dataTypeDefStr = dataTypeDef.getName().getPrefixString().substring(2); StringBuilder dataTypeName = new StringBuilder(dataTypeDefStr.substring(0, 1).toUpperCase()); dataTypeName.append(dataTypeDefStr.substring(1)); dataType = DataType.valueOf(dataTypeName.toString()); } return dataType; }
Example 3
Source File: DBQuery.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public static DataTypeDefinition getDataTypeDefinition(DictionaryService dictionaryService, QName propertyQname) { if(propertyQname == null) { return null; } PropertyDefinition propDef = dictionaryService.getProperty(propertyQname); if(propDef == null) { return null; } return propDef.getDataType(); }
Example 4
Source File: NodeContext.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public DataTypeDefinition getPropertyDataType(QName propertyName) { // get property datatype DataTypeDefinition valueDataType = propertyDatatypes.get(propertyName); if (valueDataType == null) { PropertyDefinition propDef = getDictionaryService().getProperty(propertyName); if (propDef != null) { valueDataType = propDef.getDataType(); } } return valueDataType; }
Example 5
Source File: M2PropertyDefinition.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
M2PropertyDefinition( ClassDefinition classDef, PropertyDefinition propertyDef, M2PropertyOverride override, NamespacePrefixResolver prefixResolver, Map<QName, ConstraintDefinition> modelConstraints) { this.classDef = classDef; this.name = propertyDef.getName(); this.dataType = propertyDef.getDataType(); this.propertyTypeName = this.dataType.getName(); this.m2Property = createOverriddenProperty(propertyDef, override, prefixResolver, modelConstraints); }
Example 6
Source File: SolrFacetServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public List<PropertyDefinition> getFacetableProperties(QName contentClass) { final List<PropertyDefinition> result = new ArrayList<>(); final Map<QName, PropertyDefinition> propertyDefs = dictionaryService.getPropertyDefs(contentClass); if (propertyDefs != null) { for (final Map.Entry<QName, PropertyDefinition> prop : propertyDefs.entrySet()) { final PropertyDefinition propDef = prop.getValue(); if (propDef.isIndexed()) //SHA-1308 { final Facetable propIsFacetable = propDef.getFacetable(); switch (propIsFacetable) { case TRUE: result.add(propDef); break; case FALSE: // The value is not facetable. Do nothing. break; case UNSET: // These values may be facetable. final DataTypeDefinition datatype = propDef.getDataType(); if (isNumeric(datatype) || isDateLike(datatype) || isFacetableText(datatype)) { result.add(propDef); break; } break; default: // This should never happen. If it does, it's a programming error. throw new IllegalStateException("Failed to handle " + Facetable.class.getSimpleName() + " type: " + propIsFacetable); } } } } return result; }
Example 7
Source File: DBQuery.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @param dictionaryService DictionaryService * @param propertyQName QName * @return String */ public static String getFieldName(DictionaryService dictionaryService, QName propertyQName, boolean supportBooleanFloatAndDouble) { if (propertyQName.equals(ContentModel.PROP_CREATED)) { return "audit_created"; } else if (propertyQName.equals(ContentModel.PROP_CREATOR)) { return "audit_creator"; } else if (propertyQName.equals(ContentModel.PROP_MODIFIED)) { return "audit_modified"; } else if (propertyQName.equals(ContentModel.PROP_MODIFIER)) { return "audit_modifier"; } else { PropertyDefinition propDef = dictionaryService.getProperty(propertyQName); if (propDef == null) { throw new QueryModelException("Unknown property " + propertyQName); } DataTypeDefinition dataType = propDef.getDataType(); if (dataType.getName().equals(DataTypeDefinition.ASSOC_REF)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.CATEGORY)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.DATE)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.DATETIME)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.INT)) { return "long_value"; } else if (dataType.getName().equals(DataTypeDefinition.LOCALE)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.LONG)) { return "long_value"; } else if (dataType.getName().equals(DataTypeDefinition.MLTEXT)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.NODE_REF)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.PERIOD)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.QNAME)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.TEXT)) { return "string_value"; } else if (dataType.getName().equals(DataTypeDefinition.BOOLEAN) && supportBooleanFloatAndDouble) { return "boolean_value"; } else if (dataType.getName().equals(DataTypeDefinition.FLOAT) && supportBooleanFloatAndDouble) { return "float_value"; } else if (dataType.getName().equals(DataTypeDefinition.DOUBLE) && supportBooleanFloatAndDouble) { return "double_value"; } else { throw new QueryModelException("Unsupported property type " + dataType.getName()); } } }
Example 8
Source File: DirectLuceneBuilder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected DataTypeDefinition getInDataType() { PropertyDefinition pd = dictionaryService.getProperty(alfrescoName); return pd.getDataType(); }
Example 9
Source File: SOLRAPIClient.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
private PropertyValue getPropertyValue(PropertyDefinition propertyDef, Object value) throws JSONException { PropertyValue ret = null; if(value == null || value == JSONObject.NULL) { ret = null; } else if(propertyDef == null) { // assume a string ret = new StringPropertyValue((String)value); } else { DataTypeDefinition dataType = propertyDef.getDataType(); boolean isMulti = propertyDef.isMultiValued(); if(isMulti) { if(!(value instanceof JSONArray)) { throw new IllegalArgumentException("Expected json array, got " + value.getClass().getName()); } MultiPropertyValue multi = new MultiPropertyValue(); JSONArray array = (JSONArray)value; for(int j = 0; j < array.length(); j++) { multi.addValue(getSinglePropertyValue(dataType, array.get(j))); } ret = multi; } else { ret = getSinglePropertyValue(dataType, value); } } return ret; }
Example 10
Source File: AlfrescoSolrDataModel.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
public String getAlfrescoPropertyFromSchemaField(String schemaField) { int index = schemaField.lastIndexOf("@{"); if(index == -1) { return schemaField; } String alfrescoQueryField = schemaField.substring(index+1); QName qName = QName.createQName(alfrescoQueryField); alfrescoQueryField = qName.toPrefixString(namespaceDAO); PropertyDefinition propertyDefinition = getPropertyDefinition(qName); if((propertyDefinition == null)) { return alfrescoQueryField; } if(!propertyDefinition.isIndexed() && !propertyDefinition.isStoredInIndex()) { return alfrescoQueryField; } DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType(); if(dataTypeDefinition.getName().equals(DataTypeDefinition.CONTENT)) { if(schemaField.contains("__size@")) { return alfrescoQueryField + ".size"; } else if(schemaField.contains("__locale@")) { return alfrescoQueryField + ".locale"; } else if(schemaField.contains("__mimetype@")) { return alfrescoQueryField + ".mimetype"; } else if(schemaField.contains("__encoding@")) { return alfrescoQueryField + ".encoding"; } else if(schemaField.contains("__docid@")) { return alfrescoQueryField + ".docid"; } else if(schemaField.contains("__tr_ex@")) { return alfrescoQueryField + ".tr_ex"; } else if(schemaField.contains("__tr_time@")) { return alfrescoQueryField + ".tr_time"; } else if(schemaField.contains("__tr_status@")) { return alfrescoQueryField + ".tr_status"; } else { return alfrescoQueryField; } } else { return alfrescoQueryField; } }
Example 11
Source File: AlfrescoSolrDataModel.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
public IndexedField getIndexedFieldForSpecializedPropertyMetadata(QName propertyQName, SpecializedFieldType type) { IndexedField indexedField = new IndexedField(); PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName); if((propertyDefinition == null)) { return indexedField; } if(!propertyDefinition.isIndexed() && !propertyDefinition.isStoredInIndex()) { return indexedField; } DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType(); if(dataTypeDefinition.getName().equals(DataTypeDefinition.CONTENT)) { StringBuilder builder = new StringBuilder(); builder.append(dataTypeDefinition.getName().getLocalName()); builder.append('@'); // TODO wher we support multi value propertis correctly .... builder.append(propertyDefinition.isMultiValued() ? "m" : "s"); builder.append('s'); builder.append("_"); builder.append('_'); switch (type) { case CONTENT_DOCID: builder.append("docid"); break; case CONTENT_ENCODING: builder.append("encoding"); break; case CONTENT_LOCALE: builder.append("locale"); break; case CONTENT_MIMETYPE: builder.append("mimetype"); break; case CONTENT_SIZE: builder.append("size"); break; case TRANSFORMATION_EXCEPTION: builder.append("tr_ex"); break; case TRANSFORMATION_STATUS: builder.append("tr_status"); break; case TRANSFORMATION_TIME: builder.append("tr_time"); break; default: break; } builder.append('@'); builder.append(propertyQName); indexedField.addField(builder.toString(), false, false); } else if (isDateOrDatetime(dataTypeDefinition)) { String dateDerivedSuffix = getDateDerivedSuffix(type); if (dateDerivedSuffix != null) { indexedField.addField(getDateDerivedField(propertyQName, dateDerivedSuffix), false, true); } } return indexedField; }
Example 12
Source File: AlfrescoSolrDataModel.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
private void addSortSearchFields( PropertyDefinition propertyDefinition , IndexedField indexedField) { // Can only order on single valued fields DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType(); if(dataTypeDefinition.getName().equals(DataTypeDefinition.TEXT)) { if(!propertyDefinition.isMultiValued()) { if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) { indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true); } else if (isIdentifierTextProperty(propertyDefinition.getName())) { indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false); } else { if(crossLocaleSearchDataTypes.contains(propertyDefinition.getDataType().getName()) || crossLocaleSearchProperties.contains(propertyDefinition.getName())) { indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false); } else { indexedField.addField(getFieldForText(true, true, false, propertyDefinition), false, false); } } } } if(dataTypeDefinition.getName().equals(DataTypeDefinition.MLTEXT)) { if(!propertyDefinition.isMultiValued()) { if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) { indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true); } else { if(crossLocaleSearchDataTypes.contains(propertyDefinition.getDataType().getName()) || crossLocaleSearchProperties.contains(propertyDefinition.getName())) { indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false); } else { indexedField.addField(getFieldForText(true, true, false, propertyDefinition), false, false); } } } } }
Example 13
Source File: AlfrescoSolrDataModel.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
/** * Get all the field names into which we must copy the source data * * @param propertyQName QName * @return IndexedField */ public IndexedField getIndexedFieldNamesForProperty(QName propertyQName) { // TODO: Cache and throw on model refresh IndexedField indexedField = new IndexedField(); PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName); if((propertyDefinition == null)) { return indexedField; } if(!propertyDefinition.isIndexed() && !propertyDefinition.isStoredInIndex()) { return indexedField; } DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType(); if(isTextField(propertyDefinition)) { if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.TRUE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) { indexedField.addField(getFieldForText(true, true, false, propertyDefinition), true, false); if(crossLocaleSearchDataTypes.contains(propertyDefinition.getDataType().getName()) || crossLocaleSearchProperties.contains(propertyDefinition.getName())) { indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false); } } if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH || isIdentifierTextProperty(propertyDefinition.getName()))) { indexedField.addField(getFieldForText(true, false, false, propertyDefinition), true, false); indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false); } if(dataTypeDefinition.getName().equals(DataTypeDefinition.TEXT)) { if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) { if(!propertyDefinition.isMultiValued()) { indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true); } } else if (!isIdentifierTextProperty(propertyDefinition.getName())) { if(propertyDefinition.getFacetable() == Facetable.TRUE) { indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false); } } } if(dataTypeDefinition.getName().equals(DataTypeDefinition.MLTEXT)) { if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) { if(!propertyDefinition.isMultiValued()) { indexedField.addField(getFieldForText(true, false, true, propertyDefinition), true, true); } } } if(isSuggestable(propertyQName)) { indexedField.addField("suggest_@" + propertyDefinition.getName().toString(), false, false); } } else { indexedField.addField(getFieldForNonText(propertyDefinition), false, false); } return indexedField; }
Example 14
Source File: SOLRSerializer.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") public PropertyValue serialize(QName propName, Serializable value) throws IOException, JSONException { if(value == null) { return new PropertyValue(false, "null"); } PropertyDefinition propertyDef = dictionaryService.getProperty(propName); if (propertyDef == null) { // Treat it as text return new PropertyValue(true, serializeToJSONString(value)); } DataTypeDefinition dataType = propertyDef.getDataType(); QName dataTypeName = dataType.getName(); if (propertyDef.isMultiValued()) { if(!(value instanceof Collection)) { throw new IllegalArgumentException("Multi value: expected a collection, got " + value.getClass().getName()); } Collection<Serializable> c = (Collection<Serializable>)value; JSONArray body = new JSONArray(); for(Serializable o : c) { if(dataTypeName.equals(DataTypeDefinition.MLTEXT)) { MLText source = (MLText)o; JSONArray array = new JSONArray(); for(Locale locale : source.getLocales()) { JSONObject json = new JSONObject(); json.put("locale", DefaultTypeConverter.INSTANCE.convert(String.class, locale)); json.put("value", source.getValue(locale)); array.put(json); } body.put(array); } else if(dataTypeName.equals(DataTypeDefinition.CONTENT)) { throw new RuntimeException("Multi-valued content properties are not supported"); } else { body.put(serializeToJSONString(o)); } } return new PropertyValue(false, body.toString()); } else { boolean encodeString = true; if(dataTypeName.equals(DataTypeDefinition.MLTEXT)) { encodeString = false; } else if(dataTypeName.equals(DataTypeDefinition.CONTENT)) { encodeString = false; } else { encodeString = true; } String sValue = null; if (value instanceof String && encodeString) { sValue = (String)jsonUtils.encodeJSONString(value); } else { sValue = serializeToJSONString(value); } return new PropertyValue(encodeString, sValue); } }
Example 15
Source File: QueryParameterDefImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 3 votes |
/** * QueryParameterDefImpl * * @param qName QName * @param propertyDefinition PropertyDefinition * @param hasDefaultValue boolean * @param defaultValue String */ public QueryParameterDefImpl(QName qName, PropertyDefinition propertyDefinition, boolean hasDefaultValue, String defaultValue) { this(qName, hasDefaultValue, defaultValue); this.propertyDefintion = propertyDefinition; this.dataTypeDefintion = propertyDefinition.getDataType(); }