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

The following examples show how to use org.alfresco.service.cmr.dictionary.PropertyDefinition#getName() . 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: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void addHighlightSearchFields( PropertyDefinition propertyDefinition , IndexedField indexedField)
{
    QName propertyName = propertyDefinition.getName();
    QName propertyDataTypeQName = propertyDefinition.getDataType().getName();
    String fieldName;

    if(propertyDataTypeQName.equals(DataTypeDefinition.MLTEXT))
    {
        fieldName = getStoredMLTextField(propertyName);
    }
    else if(propertyDataTypeQName.equals(DataTypeDefinition.CONTENT))
    {
        fieldName = getStoredContentField(propertyName);
    }
    else
    {
        fieldName = getStoredTextField(propertyName);
    }

    indexedField.addField(fieldName, false, false);
}
 
Example 2
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void addExactSearchFields(PropertyDefinition propertyDefinition, IndexedField indexedField)
{
    if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE)
            || !(propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH))
    {

        indexedField.addField(getFieldForText(true, false, false, propertyDefinition), true, false);
        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{
            throw new UnsupportedOperationException("Exact Term search is not supported unless you configure the field <"+propertyDefinition.getName()+"> for cross locale search");
        }
    }
}
 
Example 3
Source File: ModelValidatorImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void validateDeleteProperty(final String tenantDomain, final PropertyDefinition propDef)
{
    final QName propName = propDef.getName();

    // We need a separate transaction to do the qname delete "check"
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            return TenantUtil.runAsTenant(new TenantRunAsWork<Void>()
            {
                @Override
                public Void doWork() throws Exception
                {
                    try
                    {
                        // The property QName may not have been created in the database if no
                        // properties have been created that use it, so check first and then
                        // try to delete it.
                        if(qnameDAO.getQName(propName) != null)
                        {
                            qnameDAO.deleteQName(propName);
                        }
                    }
                    catch(DataIntegrityViolationException e)
                    {
                        // catch data integrity violation e.g. foreign key constraint exception
                        logger.debug(e);
                        throw new ModelInUseException("Failed to validate property delete, property " + propName + " is in use");
                    }

                    return null;
                }
            }, tenantDomain);
        }
    }, false, true);
}
 
Example 4
Source File: M2PropertyDefinition.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 5
Source File: SOLRTrackingComponentImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
    * {@inheritDoc}
    */
public void getNodes(NodeParameters nodeParameters, NodeQueryCallback callback)
{
    if(enabled)
    {
        QName shardPropertQName = null;
        QName shardPropertyType = null;

        if(nodeParameters.getShardProperty() != null)
        {
            PropertyDefinition pdef = QueryParserUtils.matchPropertyDefinition(NamespaceService.CONTENT_MODEL_1_0_URI, namespaceService, dictionaryService, nodeParameters.getShardProperty());
            if(pdef == null)
            {
                logger.warn("Invalid shard property: "+nodeParameters.getShardProperty());
            } else
               {
                   shardPropertyType = pdef.getDataType().getName();

                   if (!shardPropertyType.equals(DataTypeDefinition.TEXT)
                           && !shardPropertyType.equals(DataTypeDefinition.DATE)
                           && !shardPropertyType.equals(DataTypeDefinition.DATETIME)
                           && !shardPropertyType.equals(DataTypeDefinition.INT)
                           && !shardPropertyType.equals(DataTypeDefinition.LONG))
                   {
                       logger.warn("Unsupported shard property type: "+(pdef.getDataType().getName() + " for " +nodeParameters.getShardProperty()));
                   }
                   else
                   {
                       shardPropertQName = pdef.getName();
                   }
               }
        }


        List<Node> nodes = solrDAO.getNodes(nodeParameters, shardPropertQName, shardPropertyType);

        for (Node node : nodes)
        {
               if (shardRegistry != null){
                   shardRegistry.getShardInstanceByTransactionTimestamp(
                           nodeParameters.getCoreName(),
                           node.getTransaction().getCommitTimeMs()).ifPresent(
                                   shardId -> ((NodeEntity) node).setExplicitShardId(shardId));

               }

            callback.handleNode(node);
        }
    }
}
 
Example 6
Source File: AlfrescoSolrDataModel.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 * return the stored field associated to potentialProperty parameter
 */
public String mapStoredProperty(String potentialProperty, SolrQueryRequest req)
{
    if(potentialProperty.equals("asc") || potentialProperty.equals("desc") || potentialProperty.equals("_docid_"))
    {
        return potentialProperty;
    }

    if(potentialProperty.equalsIgnoreCase("score") || potentialProperty.equalsIgnoreCase("SEARCH_SCORE"))
    {
        return "score";
    }

    AlfrescoFunctionEvaluationContext functionContext =
        new AlfrescoSolr4FunctionEvaluationContext(
            getNamespaceDAO(),
            getDictionaryService(CMISStrictDictionaryService.DEFAULT),
            NamespaceService.CONTENT_MODEL_1_0_URI,
            req.getSchema());


    Pair<String, String> fieldNameAndEnding = QueryParserUtils.extractFieldNameAndEnding(potentialProperty);
    String luceneField =  functionContext.getLuceneFieldName(fieldNameAndEnding.getFirst());

    PropertyDefinition propertyDef = getPropertyDefinition(fieldNameAndEnding.getFirst());
    //Retry scan using luceneField.
    if(propertyDef == null)
    {
        if(luceneField.contains("@"))
        {
            int index = luceneField.lastIndexOf("@");
            propertyDef = getPropertyDefinition(luceneField.substring(index +1));
        }
    }

    if (propertyDef == null || propertyDef.getName() == null)
    {
        return mapNonPropertyFields(luceneField);
    }

    if (isDateOrDatetime(propertyDef.getDataType()) && isDerivedDateField(fieldNameAndEnding.getSecond()))
    {
        return getDateDerivedField(propertyDef.getName(), fieldNameAndEnding.getSecond());
    }
    else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT))
    {
        return getStoredTextField(propertyDef.getName(), fieldNameAndEnding.getSecond());
    }
    else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT))
    {
        return getStoredMLTextField(propertyDef.getName(), fieldNameAndEnding.getSecond());
    }
    else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
    {
        return getStoredContentField(propertyDef.getName(), fieldNameAndEnding.getSecond());
    }
    else
    {
        return mapAlfrescoField(FieldUse.FTS, 0, fieldNameAndEnding, luceneField, propertyDef)
                + fieldNameAndEnding.getSecond();
    }
}