Java Code Examples for org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI

The following are Jave code examples for showing how to use CONTENT_MODEL_1_0_URI of the org.alfresco.service.namespace.NamespaceService class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: RatingNamingConventionsUtil.java   View Source Code Vote up 5 votes
/**
 * This method returns a QNamePattern for the specified username and ratingSchemeName.
 * This pattern can be used when navigating child-associations looking for cm:rating nodes.
 * 
 * @param username the username to match against or <code>null</code> for all usernames.
 * @param ratingSchemeName the ratingSchemeName to match against or <code>null</code> for all ratingSchemes.
 * @return QNamePattern
 */
public QNamePattern getRatingAssocPatternForUser(String username, String ratingSchemeName)
{
    if (username == null)
    {
        username = ".*";
    }
    if (ratingSchemeName == null)
    {
        ratingSchemeName = ".*";
    }
    return new RegexQNamePattern(NamespaceService.CONTENT_MODEL_1_0_URI, username + RATING_ASSOC_SEPARATOR + ratingSchemeName);
}
 
Example 2
Project: alfresco-repository   File: DBQuery.java   View Source Code Vote up 4 votes
public static String expandQName(String toStrip, NamespacePrefixResolver namespacePrefixResolver)
{
    String qnameString;
    if(toStrip.endsWith(".size"))
    {
        qnameString = toStrip.substring(0, toStrip.length()-5);
    }
    else if(toStrip.endsWith(".mimetype"))
    {
        qnameString = toStrip.substring(0, toStrip.length()-9);
    }
    else
    {
        qnameString = toStrip;
    }
    
    
    String fieldName = qnameString;
    if(fieldName.startsWith("@"))
    {
        fieldName = fieldName.substring(1);
    }
    // Check for any prefixes and expand to the full uri
    if (fieldName.charAt(0) != '{')
    {
        int colonPosition = fieldName.indexOf(':');
        if (colonPosition == -1)
        {
            
            
            // use the default namespace
            fieldName = "{" + NamespaceService.CONTENT_MODEL_1_0_URI + "}" + fieldName;
        }
        else
        {
            String prefix = fieldName.substring(0, colonPosition);
            String uri = matchURI(prefix, namespacePrefixResolver);
            if (uri == null)
            {
                fieldName = "{" + NamespaceService.CONTENT_MODEL_1_0_URI + "}" + fieldName;
            }
            else
            {
                fieldName = "{" + uri + "}" + fieldName.substring(colonPosition + 1);
            }

        }
    }
    return fieldName;
}
 
Example 3
Project: alfresco-data-model   File: FTSTest.java   View Source Code Vote up 4 votes
public void testMapLoneStar() throws Exception
{
    final String ftsExpression = "* AND * AND * AND * AND * AND * AND * AND * AND * AND * AND *";
    AlfrescoFunctionEvaluationContext functionContext = new AlfrescoFunctionEvaluationContext(null, null, NamespaceService.CONTENT_MODEL_1_0_URI);

    Map<String, String> templates = new HashMap<String, String>();
    String keywordsTemplate = "%(cm:name cm:title cm:description ia:whatEvent ia:descriptionEvent lnk:title lnk:description TEXT TAG)";
    String keywordsKey = "keywords";
    templates.put(keywordsKey, keywordsTemplate);

    final FTSParser.Mode mode = FTSParser.Mode.DEFAULT_DISJUNCTION;
    final Connective defaultFieldConnective = Connective.OR;

    class TestMock extends FTSQueryParser.TestNodeBuilder
    {
        private void test(CommonTree initialNode, CommonTree replacedNode)
        {
            if (initialNode.getType() == FTSParser.TERM &&
                    initialNode.getChildCount() == 1 &&
                    initialNode.getChild(0).getType() == FTSParser.STAR)
            {
                // input is the lone star
                Tree node = replacedNode;
                while (true)
                {
                    if (node.getChildCount() == 1)
                    {
                        node = node.getChild(0);
                        if (node.getType() == FTSParser.TERM)
                        {
                            assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, node.getChildCount(), 2);
                            Tree child1 = node.getChild(0);
                            assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child1.getType(), FTSParser.ID);
                            assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child1.getText(), "T");
                            Tree child2 = node.getChild(1);
                            assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child2.getType(), FTSParser.FIELD_REF);
                            assertEquals("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR, child2.getChild(0).getText(), "ISNODE");
                            // checking done
                            break;
                        }
                    }
                    else
                    {
                        // wrong structure of the replaced node
                        fail("Lone star should be mapped to " + FTSQueryParser.VALUE_REPLACELONESTAR);
                    }
                }
            }
        }
        
        @Override
        protected CommonTree build(CommonTree fieldReferenceNode, CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
                Selector selector, Map<String, Column> columnMap, Map<String, CommonTree> templateTrees, String defaultField)
        {
            CommonTree testNode = super.build(fieldReferenceNode, argNode, factory, functionEvaluationContext, selector, columnMap, templateTrees, defaultField);
            test(argNode, testNode);
            return testNode;
        }
    }

    FTSQueryParser.setTestNodeBuilder(new TestMock());
    try
    {
        FTSQueryParser.buildFTS(ftsExpression, new LuceneQueryModelFactory(), functionContext, null, null,
                mode, defaultFieldConnective, templates, keywordsKey, FTSQueryParser.RerankPhase.SINGLE_PASS);
    }
    finally
    {
        // set default logic
        FTSQueryParser.setTestNodeBuilder(new FTSQueryParser.TestNodeBuilder());
    }
}