private SampleOntologyDetails createSampleOntology() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); getWorkspaceRepository().add(workspaceId, "Junit Workspace", user); Concept publicConcept = createConcept(PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, PUBLIC); Concept sandboxedConcept = createConcept(SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, workspaceId); Relationship publicRelationship = createRelationship(PUBLIC_RELATIONSHIP_IRI, PUBLIC); Relationship sandboxedRelationship = createRelationship(SANDBOX_RELATIONSHIP_IRI, workspaceId); OntologyProperty publicProperty = createProperty(PUBLIC_PROPERTY_IRI, PUBLIC_DISPLAY_NAME, publicConcept, publicRelationship, PUBLIC); OntologyProperty sandboxedProperty = createProperty(SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, Arrays.asList(publicConcept, sandboxedConcept), Arrays.asList(publicRelationship, sandboxedRelationship), workspaceId); OntologyProperty sandboxedPropertyOnlySandboxedConcept = createProperty(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT, SANDBOX_DISPLAY_NAME, Arrays.asList(sandboxedConcept), Arrays.asList(), workspaceId); getOntologyRepository().clearCache(); return new SampleOntologyDetails( publicConcept.getId(), publicRelationship.getId(), publicProperty.getId(), sandboxedConcept.getId(), sandboxedRelationship.getId(), sandboxedProperty.getId(), sandboxedPropertyOnlySandboxedConcept.getId()); }
@Test public void testAddingPublicPropertyToPublicConceptsAndRelationships() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); getWorkspaceRepository().add(workspaceId, "Junit Workspace", user); createConcept(PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, PUBLIC); createRelationship(PUBLIC_RELATIONSHIP_IRI, PUBLIC); OntologyProperty publicProperty = createProperty(PUBLIC_PROPERTY_IRI, PUBLIC_DISPLAY_NAME, PUBLIC); getOntologyRepository().clearCache(); try { getOntologyRepository().updatePropertyDomainIris(publicProperty, Sets.newHashSet(PUBLIC_CONCEPT_IRI, PUBLIC_RELATIONSHIP_IRI), systemUser, workspaceId); fail(); } catch (UnsupportedOperationException uoe) { // this shouldn't be supported yet } }
@Test public void testAddingPublicPropertyToSandboxedConceptsAndRelationships() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); getWorkspaceRepository().add(workspaceId, "Junit Workspace", user); createConcept(SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, workspaceId); createRelationship(SANDBOX_RELATIONSHIP_IRI, workspaceId); OntologyProperty publicProperty = createProperty(PUBLIC_PROPERTY_IRI, PUBLIC_DISPLAY_NAME, PUBLIC); getOntologyRepository().clearCache(); try { getOntologyRepository().updatePropertyDomainIris(publicProperty, Sets.newHashSet(SANDBOX_CONCEPT_IRI, SANDBOX_RELATIONSHIP_IRI), systemUser, workspaceId); fail(); } catch (UnsupportedOperationException uoe) { // this shouldn't be supported yet } }
@Test public void testAddingSandboxedPropertyToSandboxedConceptsAndRelationships() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); getWorkspaceRepository().add(workspaceId, "Junit Workspace", user); createConcept(SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, workspaceId); createRelationship(SANDBOX_RELATIONSHIP_IRI, workspaceId); OntologyProperty sandboxedProperty = createProperty(SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, workspaceId); getOntologyRepository().clearCache(); getOntologyRepository().updatePropertyDomainIris(sandboxedProperty, Sets.newHashSet(SANDBOX_CONCEPT_IRI, SANDBOX_RELATIONSHIP_IRI), systemUser, workspaceId); getOntologyRepository().clearCache(); Concept sandboxedConcept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); assertEquals(1, sandboxedConcept.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, sandboxedConcept.getProperties().iterator().next().getIri()); Relationship sandboxedRelationship = getOntologyRepository().getRelationshipByIRI(SANDBOX_RELATIONSHIP_IRI, workspaceId); assertEquals(1, sandboxedRelationship.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, sandboxedRelationship.getProperties().iterator().next().getIri()); }
@Test public void testAddingSandboxedPropertyToPublicConceptsAndRelationships() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); getWorkspaceRepository().add(workspaceId, "Junit Workspace", user); createConcept(PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, PUBLIC); createRelationship(PUBLIC_RELATIONSHIP_IRI, PUBLIC); OntologyProperty sandboxedProperty = createProperty(SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, workspaceId); getOntologyRepository().clearCache(); getOntologyRepository().updatePropertyDomainIris(sandboxedProperty, Sets.newHashSet(PUBLIC_CONCEPT_IRI, PUBLIC_RELATIONSHIP_IRI), systemUser, workspaceId); getOntologyRepository().clearCache(); // ensure that it's there in the sandbox Concept publicConcept = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, workspaceId); assertEquals(1, publicConcept.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, publicConcept.getProperties().iterator().next().getIri()); Relationship publicRelationship = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, workspaceId); assertEquals(1, publicRelationship.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, publicRelationship.getProperties().iterator().next().getIri()); // ensure that it's not there outside the sandbox publicConcept = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, PUBLIC); assertEquals(0, publicConcept.getProperties().size()); publicRelationship = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, PUBLIC); assertEquals(0, publicRelationship.getProperties().size()); }
@Test public void testAddingPublicConceptsToPublicRelationships() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); getWorkspaceRepository().add(workspaceId, "Junit Workspace", user); Concept publicConcept = createConcept(PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, PUBLIC); Concept publicConceptB = createConcept(PUBLIC_CONCEPT_IRI + 'b', PUBLIC_DISPLAY_NAME, PUBLIC); createRelationship(PUBLIC_RELATIONSHIP_IRI, PUBLIC); getOntologyRepository().clearCache(); try { getOntologyRepository().addDomainConceptsToRelationshipType(PUBLIC_RELATIONSHIP_IRI, Collections.singletonList(publicConcept.getIRI()), systemUser, workspaceId); fail(); } catch (UnsupportedOperationException uoe) { // this shouldn't be supported yet } try { getOntologyRepository().addRangeConceptsToRelationshipType(PUBLIC_RELATIONSHIP_IRI, Collections.singletonList(publicConceptB.getIRI()), systemUser, workspaceId); fail(); } catch (UnsupportedOperationException uoe) { // this shouldn't be supported yet } }