private Concept createConcept(String iri, String displayName, String workspaceId) { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); return getOntologyRepository().getOrCreateConcept(thing, iri, displayName, null, systemUser, workspaceId); }
graphAuthorizationRepository.addAuthorizationToGraph(VisalloVisibility.SUPER_USER_VISIBILITY_STRING); Concept userConcept = ontologyRepository.getOrCreateConcept(null, USER_CONCEPT_IRI, "visalloUser", null, false, getSystemUser(), PUBLIC); userConceptId = userConcept.getIRI();
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingConceptsWithNoUserOrWorkspace() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, null, PUBLIC); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingSandboxedConceptsWithoutAddPermissionPrivilege() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingPublicConceptsWithoutPublishPrivilege() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, user, PUBLIC); }
@Test public void testPublishingNewVertexAndConceptWithoutOntologyPublishPrivilege() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD)); String newConceptIri = "new-concept"; getOntologyRepository().getOrCreateConcept(thingConcept, newConceptIri, "Junit Concept", null, user, workspace.getWorkspaceId()); getOntologyRepository().clearCache(); doTestPublishVertexAdd(newConceptIri, "Unable to publish concept Junit Concept", SandboxStatus.PRIVATE); }
@Test public void testPublishingNewVertexAndConcept() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); String newConceptIri = "new-concept"; getOntologyRepository().getOrCreateConcept(thingConcept, newConceptIri, "Junit Concept", null, user, workspace.getWorkspaceId()); getOntologyRepository().clearCache(); doTestPublishVertexAdd(newConceptIri, null, SandboxStatus.PUBLIC); }
@Test(expected = VisalloAccessDeniedException.class) public void testPublishingConceptsWithoutPublishPrivilege() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); Concept sandboxedConcept = getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); getOntologyRepository().clearCache(); getOntologyRepository().publishConcept(sandboxedConcept, user, workspaceId); }
protected void addConceptWithIntent(String conceptIri, String... intents) { Concept concept = getOntologyRepository().getOrCreateConcept( null, conceptIri, conceptIri, null, getUserRepository().getSystemUser(), null ); for (String intent : intents) { concept.addIntent(intent, getUserRepository().getSystemUser(), getGraphAuthorizations()); } } }
@Test public void testPublishingConcepts() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); Concept sandboxedConcept = getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); getOntologyRepository().publishConcept(sandboxedConcept, user, workspaceId); getOntologyRepository().clearCache(); Concept publicConcept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, PUBLIC); assertEquals(SANDBOX_DISPLAY_NAME, publicConcept.getDisplayName()); }
@Test public void testCreatingSandboxedConcepts() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); getOntologyRepository().clearCache(); Concept noWorkspace = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, PUBLIC); assertNull(noWorkspace); Concept withWorkspace = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); assertEquals(SANDBOX_DISPLAY_NAME, withWorkspace.getDisplayName()); }
@Test public void testCreatingPublicConcepts() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, user, PUBLIC); getOntologyRepository().clearCache(); Concept noWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, PUBLIC); assertEquals(PUBLIC_DISPLAY_NAME, noWorkspace.getDisplayName()); Concept withWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, workspaceId); assertEquals(PUBLIC_DISPLAY_NAME, withWorkspace.getDisplayName()); }
@Test public void testExceptionDeletingSandboxedConceptsWithDescendants() throws Exception { createSampleOntology(); Concept concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); // Add a descendant getOntologyRepository().getOrCreateConcept(concept, SANDBOX_CONCEPT_IRI + "child", SANDBOX_DISPLAY_NAME, null, systemUser, workspaceId); getOntologyRepository().clearCache(workspaceId); thrown.expect(VisalloException.class); thrown.expectMessage("Unable to delete concept that have children"); getOntologyRepository().deleteConcept(SANDBOX_CONCEPT_IRI, adminUser, workspaceId); }
@Test public void testCreatingPublicConceptsAsSystem() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, systemUser, PUBLIC); getOntologyRepository().clearCache(); Concept noWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, PUBLIC); assertEquals(PUBLIC_DISPLAY_NAME, noWorkspace.getDisplayName()); Concept withWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, workspaceId); assertEquals(PUBLIC_DISPLAY_NAME, withWorkspace.getDisplayName()); }
@Override public void before() throws Exception { super.before(); user = getUserRepository().findOrAddUser("base-junit", "Base Junit", "base-junit@visallo.com", "password"); User systemUser = getUserRepository().getSystemUser(); Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(systemUser); thingConcept = getOntologyRepository().getEntityConcept(PUBLIC); List<Concept> things = Collections.singletonList(thingConcept); Relationship hasEntityRel = getOntologyRepository().getOrCreateRelationshipType(null, things, things, "has-entity-iri", true, systemUser, PUBLIC); hasEntityRel.addIntent("entityHasImage", user, authorizations); getOntologyRepository().getOrCreateConcept(thingConcept, JUNIT_CONCEPT_TYPE, "Junit Concept", null, systemUser, PUBLIC); getOntologyRepository().getOrCreateRelationshipType(null, things, things, JUNIT_EDGE_LABEL, true, systemUser, PUBLIC); OntologyPropertyDefinition propertyDefinition = new OntologyPropertyDefinition(things, JUNIT_PROPERTY_NAME, "Junit Property", PropertyType.STRING); propertyDefinition.setTextIndexHints(Collections.singleton(TextIndexHint.EXACT_MATCH)); propertyDefinition.setUserVisible(true); getOntologyRepository().getOrCreateProperty(propertyDefinition, systemUser, PUBLIC); getOntologyRepository().clearCache(); workspace = getWorkspaceRepository().add("ws1", "workspace 1", user); workspaceAuthorizations = getAuthorizationRepository().getGraphAuthorizations(user, workspace.getWorkspaceId()); }
Concept concept = ontologyRepository.getOrCreateConcept(parent, iri, displayName, glyphIconHref, color, null, user, workspaceId);