@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 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 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()); }
Collections.addAll(domainIris, relationshipIris); ontologyRepository.updatePropertyDomainIris(property, domainIris, user, workspaceId);