Example usage for java.util Collections EMPTY_SET

List of usage examples for java.util Collections EMPTY_SET

Introduction

In this page you can find the example usage for java.util Collections EMPTY_SET.

Prototype

Set EMPTY_SET

To view the source code for java.util Collections EMPTY_SET.

Click Source Link

Document

The empty set (immutable).

Usage

From source file:org.mindswap.pellet.KnowledgeBase.java

/**
 * Returns the (named) classes individual belongs to. Depending on the second parameter the 
 * result will include either all types or only the direct types.
 * /*www . ja  va2  s . c  o m*/
 * @param ind An individual name
 * @param direct If true return only the direct types, otherwise return all types
 * @return A set of sets, where each set in the collection represents an equivalence 
 * class. The elements of the inner class are ATermAppl objects. 
 */
public Set getTypes(ATermAppl ind, boolean direct) {
    if (!isIndividual(ind)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(ind + " is not an individual!");
    }

    realize();

    return taxonomy.getTypes(ind, direct);
}

From source file:org.mindswap.pellet.KnowledgeBase.java

/**
 * Get all the (named) classes individual belongs to. 
 *  //from w w  w.  ja  v a 2  s  . c  om
 * <p>*** This function will first realize the whole ontology ***</p>
 * 
 * @param ind An individual name
 * @return A set of sets, where each set in the collection represents an equivalence 
 * class. The elements of the inner class are ATermAppl objects. 
 */
public Set getTypes(ATermAppl ind) {
    if (!isIndividual(ind)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(ind + " is not an individual!");
    }

    realize();

    return taxonomy.getTypes(ind);
}

From source file:org.mindswap.pellet.KnowledgeBase.java

/** 
 * Returns all the instances of concept c. If TOP concept is used every individual in the
 * knowledge base will be returned//from ww  w  .j a  v  a2 s.co  m
 * 
 * @param c class whose instanceses are returned 
 * @return A set of ATerm objects
 */
public Set getInstances(ATermAppl c) {
    if (!isClass(c)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(c + " is not a class!");
    }

    if (isRealized() && taxonomy.contains(c))
        return taxonomy.getInstances(c);

    return new HashSet(retrieve(c, individuals));
}

From source file:org.mindswap.pellet.KnowledgeBase.java

/**
 * Returns the instances of class c. Depending on the second parameter the resulting
 * list will include all or only the direct instances. An individual x is a direct
 * instance of c iff x is of type c and there is no subclass d of c such that x is of
 * type d. //from w  w w.ja v  a2s .c  om
 * 
 * <p>*** This function will first realize the whole ontology ***</p>
 * 
 * @param c class whose instances are returned
 * @param direct if true return only the direct instances, otherwise return all the instances
 * @return A set of ATerm objects
 */
public Set getInstances(ATermAppl c, boolean direct) {
    if (!isClass(c)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(c + " is not a class!");
    }

    if (!direct)
        return getInstances(c);

    if (ATermUtils.isPrimitive(c)) {
        realize();

        return taxonomy.getInstances(c, direct);
    }

    return Collections.EMPTY_SET;
}

From source file:org.mindswap.pellet.KnowledgeBase.java

/**
 * Returns all the classes that are equivalent to class c, excluding c itself. 
 * //w w w.j  a  v a2 s  .  c o  m
 * <p>*** This function will first classify the whole ontology ***</p>
 * 
 * @param c class whose equivalent classes are found
 * @return A set of ATerm objects
 */
public Set getEquivalentClasses(ATermAppl c) {
    c = ATermUtils.normalize(c);

    if (!isClass(c)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(c + " is not a class!");
    }

    classify();

    if (!taxonomy.contains(c))
        builder.classify(c);

    return taxonomy.getEquivalents(c);
}

From source file:org.mindswap.pellet.KnowledgeBase.java

/**
 * Returns all the classes that are equivalent to class c, including c itself.
 * /*from  ww  w .ja v  a2s .  c  om*/
 * <p>*** This function will first classify the whole ontology ***</p>
 * 
 * @param c class whose equivalent classes are found
 * @return A set of ATerm objects
 */
public Set getAllEquivalentClasses(ATermAppl c) {
    c = ATermUtils.normalize(c);

    if (!isClass(c)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(c + " is not a class!");
    }

    classify();

    if (!taxonomy.contains(c))
        builder.classify(c);

    return taxonomy.getAllEquivalents(c);
}

From source file:org.cloudfoundry.identity.uaa.scim.endpoints.ScimGroupEndpointsMockMvcTests.java

@Test
public void add_member_to_nonexistent_group() throws Exception {
    ScimUser user = createUserAndAddToGroups(IdentityZone.getUaa(), Collections.EMPTY_SET);
    ScimGroupMember scimGroupMember = new ScimGroupMember(user.getId(), ScimGroupMember.Type.USER,
            Arrays.asList(ScimGroupMember.Role.MEMBER, ScimGroupMember.Role.READER));
    MockHttpServletRequestBuilder post = post("/Groups/nonexistent-group-id/members")
            .header("Authorization", "Bearer " + scimWriteToken).header("Content-Type", APPLICATION_JSON_VALUE)
            .content(JsonUtils.writeValueAsString(scimGroupMember));
    getMockMvc().perform(post).andExpect(status().isNotFound());
}

From source file:org.mindswap.pellet.KnowledgeBase.java

/**
 * Returns the (named) subclasses of class c. Depending onthe second parameter the result
 * will include either all subclasses or only the direct subclasses.
 * /*from   ww  w.  j ava 2  s .  com*/
 * A class d is a direct subclass of c iff
 * <ol>
 *   <li>d is subclass of c</li> 
 *   <li>there is no other class x different from c and d such that x is subclass 
 *   of c and d is subclass of x</li>
 * </ol> 
 * The class c itself is not included in the list but all the other classes that
 * are sameAs c are put into the list. Also note that the returned
 * list will always have at least one element. The list will either include one other
 * concept from the hierachy or the BOTTOM concept if no other class is subsumed by c. 
 * By definition BOTTOM concept is subclass of every concept. 
 * 
 * <p>*** This function will first classify the whole ontology ***</p>
 * 
 * @param c class whose subclasses are returned
 * @param direct If true return only the direct subclasses, otherwise return all the subclasses
 * @return A set of sets, where each set in the collection represents an equivalence 
 * class. The elements of the inner class are ATermAppl objects. 
 */
public Set getSubClasses(ATermAppl c, boolean direct) {
    c = ATermUtils.normalize(c);

    if (!isClass(c)) {
        if (PelletOptions.SILENT_UNDEFINED_ENTITY_HANDLING)
            return Collections.EMPTY_SET;
        else
            throw new UnsupportedFeatureException(c + " is not a class!");
    }

    classify();

    if (!taxonomy.contains(c))
        builder.classify(c);

    return taxonomy.getSubs(c, direct);
}

From source file:gov.nih.nci.evs.browser.utils.MetaTreeUtils.java

public HashMap getSubconcepts(String scheme, String version, String code, String sab, String[] asso_names,
        boolean associationsNavigatedFwd) {
    HashSet hset = new HashSet();
    HashMap hmap = new HashMap();
    TreeItem ti = null;//from  www  .  j ava2 s  .c o m
    //Vector w = new Vector();

    long ms = System.currentTimeMillis();

    Set<String> codesToExclude = Collections.EMPTY_SET;
    boolean fwd = true;

    CodingSchemeVersionOrTag csvt = new CodingSchemeVersionOrTag();

    try {
        LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
        LexBIGServiceConvenienceMethods lbscm = (LexBIGServiceConvenienceMethods) lbSvc
                .getGenericExtension("LexBIGServiceConvenienceMethods");
        lbscm.setLexBIGService(lbSvc);
        String name = getCodeDescription(scheme, csvt, code);
        ti = new TreeItem(code, name);
        ti._expandable = false;

        CodedNodeGraph cng = null;
        cng = lbSvc.getNodeGraph(scheme, null, null);

        if (sab != null) {
            cng = cng.restrictToAssociations(Constructors.createNameAndValueList(_hierAssocToChildNodes),
                    Constructors.createNameAndValueList("source", sab));
        } else {
            cng = cng.restrictToAssociations(Constructors.createNameAndValueList(_hierAssocToChildNodes), null);
        }

        CodedNodeSet.PropertyType[] propertytypes = null;
        if (_resolveConcept) {
            propertytypes = new PropertyType[] { PropertyType.PRESENTATION };
        }

        // int resolveCodedEntryDepth = 0;
        ResolvedConceptReferenceList branch = null;
        branch = cng.resolveAsList(Constructors.createConceptReference(code, scheme), !associationsNavigatedFwd,
                associationsNavigatedFwd, Integer.MAX_VALUE, 2, null, propertytypes, null, -1);

        if (branch.getResolvedConceptReferenceCount() > 0) {
            Enumeration<ResolvedConceptReference> refEnum = (Enumeration<ResolvedConceptReference>) branch
                    .enumerateResolvedConceptReference();

            while (refEnum.hasMoreElements()) {
                ResolvedConceptReference ref = refEnum.nextElement();
                // AssociationList childAssociationList = ref.getTargetOf();
                AssociationList childAssociationList = ref.getSourceOf();

                if (childAssociationList == null) {
                    return hmap;
                }

                // Process each association defining children ...
                for (Association child : childAssociationList.getAssociation()) {
                    String childNavText = getDirectionalLabel(scheme, csvt, child, associationsNavigatedFwd);
                    // Each association may have multiple children ...
                    AssociatedConceptList branchItemList = child.getAssociatedConcepts();
                    for (AssociatedConcept branchItemNode : branchItemList.getAssociatedConcept()) {

                        if (isValidForSAB(branchItemNode, sab)) {
                            String branchItemCode = branchItemNode.getCode();
                            // Add here if not in the list of excluded
                            // codes.
                            // This is also where we look to see if another
                            // level
                            // was indicated to be available. If so, mark
                            // the
                            // entry with a '+' to indicate it can be
                            // expanded.
                            if (!codesToExclude.contains(branchItemCode)) {

                                if (!hset.contains(branchItemCode)) {
                                    hset.add(branchItemCode);

                                    TreeItem childItem = new TreeItem(branchItemCode,
                                            branchItemNode.getEntityDescription().getContent());

                                    childItem._expandable = false;

                                    AssociationList grandchildBranch = branchItemNode.getSourceOf();
                                    if (grandchildBranch != null) {

                                        for (Association grandchild : grandchildBranch.getAssociation()) {

                                            java.lang.String association_name = grandchild.getAssociationName();

                                            // String grandchildNavText =
                                            // getDirectionalLabel(lbscm,
                                            // scheme, csvt, child,
                                            // associationsNavigatedFwd);
                                            // Each association may have
                                            // multiple children ...
                                            AssociatedConceptList grandchildbranchItemList = grandchild
                                                    .getAssociatedConcepts();
                                            for (AssociatedConcept grandchildbranchItemNode : grandchildbranchItemList
                                                    .getAssociatedConcept()) {

                                                if (isValidForSAB(grandchildbranchItemNode, sab)) {
                                                    childItem._expandable = true;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    ti.addChild(childNavText, childItem);
                                    ti._expandable = true;
                                }
                            }
                        }
                    }
                }
            }
        }
        hmap.put(code, ti);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    _logger.debug(
            "Run time (milliseconds) getSubconcepts: " + (System.currentTimeMillis() - ms) + " to resolve ");
    return hmap;
}

From source file:org.matonto.ontology.rest.impl.OntologyRestImplTest.java

@Test
public void testGetClassesInOntologyWhenNoClasses() {
    when(ontology.getAllClasses()).thenReturn(Collections.EMPTY_SET);

    Response response = target().path("ontologies/" + encode(ontologyIRI.stringValue()) + "/classes")
            .queryParam("branchId", branchId.stringValue()).queryParam("commitId", commitId.stringValue())
            .request().get();//from   w w w.j a v a2 s  . c  o m

    assertEquals(response.getStatus(), 200);
    verify(ontologyManager).retrieveOntology(any(Resource.class), any(Resource.class), any(Resource.class));
    assertGetOntology(true);
    assertClasses(getResponse(response), Collections.EMPTY_SET);
}