OntologyProperty property = ontologyRepository.getPropertyByIRI(iri, workspaceId); if (property == null) { publishDataByPropertyIri.get(iri).forEach(data ->
String propertyName = obj.getString("propertyName"); PropertyType propertyDataType = PropertyType.DATE; OntologyProperty property = ontologyRepository.getPropertyByIRI(propertyName, searchOptions.getWorkspaceId());
@Test public void testDeletingProperties() throws Exception { createSampleOntology(); OntologyProperty property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertTrue("Property exists", property != null); getOntologyRepository().deleteProperty(SANDBOX_PROPERTY_IRI, adminUser, workspaceId); getOntologyRepository().clearCache(workspaceId); property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertTrue("Property is deleted", property == null); }
private void validateTestOwlExtendedDataTables() { OntologyProperty personTable = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#personExtendedDataTable", PUBLIC); assertTrue("personTable should be an instance of " + ExtendedDataTableProperty.class.getName(), personTable instanceof ExtendedDataTableProperty); ExtendedDataTableProperty edtp = (ExtendedDataTableProperty) personTable; ImmutableList<String> columns = edtp.getTablePropertyIris(); assertEquals(2, columns.size()); assertTrue("", columns.contains(TEST_IRI + "#personExtendedDataTableColumn1")); assertTrue("", columns.contains(TEST_IRI + "#personExtendedDataTableColumn2")); }
@Test public void testCreatingPublicProperty() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition(thing, PUBLIC_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, user, PUBLIC); getOntologyRepository().clearCache(); OntologyProperty noWorkspace = getOntologyRepository().getPropertyByIRI(PUBLIC_PROPERTY_IRI, PUBLIC); assertEquals(PUBLIC_PROPERTY_IRI, noWorkspace.getIri()); OntologyProperty withWorkspace = getOntologyRepository().getPropertyByIRI(PUBLIC_PROPERTY_IRI, workspaceId); assertEquals(PUBLIC_PROPERTY_IRI, withWorkspace.getIri()); }
@Test public void testDeletingSandboxedConcepts() throws Exception { createSampleOntology(); Concept concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); assertTrue("Concept exists", concept != null && concept.getIRI().equals(SANDBOX_CONCEPT_IRI)); OntologyProperty property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT, workspaceId); assertTrue("Property exists", property != null && property.getIri().equals(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT)); assertTrue("Concept has property", concept.getProperties().stream().anyMatch(ontologyProperty -> ontologyProperty.getIri().equals(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT))); getOntologyRepository().deleteConcept(SANDBOX_CONCEPT_IRI, adminUser, workspaceId); getOntologyRepository().clearCache(workspaceId); concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); assertTrue("Concept should have been deleted", concept == null); property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT, workspaceId); assertTrue("Property only used in this concept is deleted", property == null); property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertTrue("Property used in other concepts is updated", property != null); assertEquals(1, property.getConceptIris().size()); assertEquals(PUBLIC_CONCEPT_IRI, property.getConceptIris().get(0)); }
@Test public void testCreatingPublicPropertyAsSystem() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition(thing, PUBLIC_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, systemUser, PUBLIC); getOntologyRepository().clearCache(); OntologyProperty noWorkspace = getOntologyRepository().getPropertyByIRI(PUBLIC_PROPERTY_IRI, PUBLIC); assertEquals(PUBLIC_PROPERTY_IRI, noWorkspace.getIri()); OntologyProperty withWorkspace = getOntologyRepository().getPropertyByIRI(PUBLIC_PROPERTY_IRI, workspaceId); assertEquals(PUBLIC_PROPERTY_IRI, withWorkspace.getIri()); }
@Test public void testDependenciesBetweenOntologyFilesShouldNotChangeParentProperties() throws Exception { loadTestOwlFile(); importTestOntologyFile(TEST01_OWL, TEST01_IRI); validateTestOwlRelationship(); validateTestOwlConcepts(3); validateTestOwlProperties(); OntologyProperty aliasProperty = getOntologyRepository().getPropertyByIRI(TEST01_IRI + "#alias", PUBLIC); Concept person = getOntologyRepository().getConceptByIRI(TEST_IRI + "#person", PUBLIC); assertTrue(person.getProperties() .stream() .anyMatch(p -> p.getIri().equals(aliasProperty.getIri())) ); }
@Test public void testDeletingSandboxedRelationships() throws Exception { createSampleOntology(); Relationship relationship = getOntologyRepository().getRelationshipByIRI(SANDBOX_RELATIONSHIP_IRI, workspaceId); String propertyThatShouldBeDeleted = SANDBOX_PROPERTY_IRI + ".relationship"; createProperty(propertyThatShouldBeDeleted, SANDBOX_DISPLAY_NAME, Arrays.asList(), Arrays.asList(relationship), workspaceId); getOntologyRepository().clearCache(workspaceId); relationship = getOntologyRepository().getRelationshipByIRI(SANDBOX_RELATIONSHIP_IRI, workspaceId); OntologyProperty property = getOntologyRepository().getPropertyByIRI(propertyThatShouldBeDeleted, workspaceId); assertTrue("Property exists", property != null && property.getIri().equals(propertyThatShouldBeDeleted)); assertTrue("Relationship has property", relationship.getProperties().stream().anyMatch(ontologyProperty -> ontologyProperty.getIri().equals(propertyThatShouldBeDeleted))); getOntologyRepository().deleteRelationship(SANDBOX_RELATIONSHIP_IRI, adminUser, workspaceId); getOntologyRepository().clearCache(workspaceId); relationship = getOntologyRepository().getRelationshipByIRI(SANDBOX_RELATIONSHIP_IRI, workspaceId); assertTrue("Relationship should have been deleted", relationship == null); property = getOntologyRepository().getPropertyByIRI(propertyThatShouldBeDeleted, workspaceId); assertTrue("Property only used in this relationship is deleted", property == null); property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertTrue("Property used in other relationships is updated", property != null); assertEquals(1, property.getRelationshipIris().size()); assertEquals(PUBLIC_RELATIONSHIP_IRI, property.getRelationshipIris().get(0)); }
OntologyProperty property = ontologyRepository.getPropertyByIRI(propertyAddition.getIri(), OntologyRepository.PUBLIC); if (property == null) { return new ValidationResult("Property: " + propertyAddition.getIri() + " does not exist in the ontology");
private void addProperties(ClientApiImportProperty[] properties, List<VisalloPropertyUpdate> changedProperties, VertexBuilder vertexBuilder, VisibilityJson visibilityJson, Workspace workspace, User user) throws ParseException { for (ClientApiImportProperty property : properties) { OntologyProperty ontologyProperty = ontologyRepository.getPropertyByIRI(property.getName(), workspace.getWorkspaceId()); if (ontologyProperty == null) { ontologyProperty = ontologyRepository.getRequiredPropertyByIntent(property.getName(), workspace.getWorkspaceId()); } Object value = ontologyProperty.convertString(property.getValue()); VisalloProperty prop = ontologyProperty.getVisalloProperty(); PropertyMetadata propMetadata = new PropertyMetadata(user, visibilityJson, visibilityTranslator.getDefaultVisibility()); for (Map.Entry<String, Object> metadataEntry : property.getMetadata().entrySet()) { propMetadata.add(metadataEntry.getKey(), metadataEntry.getValue(), visibilityTranslator.getDefaultVisibility()); } //noinspection unchecked prop.updateProperty(changedProperties, null, vertexBuilder, property.getKey(), value, propMetadata); } }
@Test public void testPublishingProperty() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); List<Concept> things = Collections.singletonList(thing); Relationship publicRelationship = getOntologyRepository().getOrCreateRelationshipType(null, things, things, PUBLIC_RELATIONSHIP_IRI, true, systemUser, PUBLIC); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition( things, Collections.singletonList(publicRelationship), SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); OntologyProperty sandboxedProperty = getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, user, workspaceId); getOntologyRepository().publishProperty(sandboxedProperty, user, workspaceId); getOntologyRepository().clearCache(); OntologyProperty publicProperty = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, PUBLIC); assertEquals(SANDBOX_PROPERTY_IRI, publicProperty.getIri()); thing = getOntologyRepository().getEntityConcept(PUBLIC); publicRelationship = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, PUBLIC); assertEquals(1, thing.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, thing.getProperties().iterator().next().getIri()); assertEquals(1, publicRelationship.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, publicRelationship.getProperties().iterator().next().getIri()); }
@Test public void testCreatingSandboxedProperty() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); List<Concept> things = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); Relationship publicRelationship = getOntologyRepository().getOrCreateRelationshipType(null, things, things, PUBLIC_RELATIONSHIP_IRI, true, systemUser, PUBLIC); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition( things, Collections.singletonList(publicRelationship), SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, user, workspaceId); getOntologyRepository().clearCache(); OntologyProperty noWorkspace = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, PUBLIC); assertNull(noWorkspace); Concept thing = getOntologyRepository().getEntityConcept(PUBLIC); publicRelationship = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, PUBLIC); assertEquals(0, thing.getProperties().size()); assertEquals(0, publicRelationship.getProperties().size()); OntologyProperty withWorkspace = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertEquals(SANDBOX_PROPERTY_IRI, withWorkspace.getIri()); thing = getOntologyRepository().getEntityConcept(workspaceId); publicRelationship = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, workspaceId); assertEquals(1, thing.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, thing.getProperties().iterator().next().getIri()); assertEquals(1, publicRelationship.getProperties().size()); assertEquals(SANDBOX_PROPERTY_IRI, publicRelationship.getProperties().iterator().next().getIri()); }
OntologyProperty property = ontologyRepository.getPropertyByIRI(propertyIri, workspaceId); if (property == null) { OntologyPropertyDefinition def = new OntologyPropertyDefinition(concepts, relationships, propertyIri, displayName, type);
private void validateTestOwlProperties() { OntologyProperty nameProperty = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#name", PUBLIC); assertEquals("Name", nameProperty.getDisplayName()); assertEquals(PropertyType.STRING, nameProperty.getDataType()); ); OntologyProperty firstMetProperty = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#firstMet", PUBLIC); assertEquals("First Met", firstMetProperty.getDisplayName()); assertEquals(PropertyType.DATE, firstMetProperty.getDataType()); OntologyProperty favColorProperty = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#favoriteColor", PUBLIC); assertEquals("Favorite Color", favColorProperty.getDisplayName()); possibleValues = favColorProperty.getPossibleValues();
String propertyName = propertyPublishItem.getName(); OntologyProperty ontologyProperty = ontologyRepository.getPropertyByIRI(propertyName, workspaceId); checkNotNull(ontologyProperty, "Could not find ontology property: " + propertyName); if (!ontologyProperty.getUserVisible() || propertyName.equals(VisalloProperties.ENTITY_IMAGE_VERTEX_ID.getPropertyName())) {
private void validateChangedOwlProperties() throws IOException { OntologyProperty nameProperty = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#name", PUBLIC); assertEquals("http://visallo.org/test#name", nameProperty.getDisplayName()); assertEquals(PropertyType.STRING, nameProperty.getDataType()); assertNull(possibleValues); OntologyProperty firstMetProperty = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#firstMet", PUBLIC); assertEquals("First Met", firstMetProperty.getDisplayName()); assertEquals(PropertyType.DATE, firstMetProperty.getDataType()); OntologyProperty favColorProperty = getOntologyRepository().getPropertyByIRI(TEST_IRI + "#favoriteColor", PUBLIC); assertEquals("Favorite Color", favColorProperty.getDisplayName()); possibleValues = favColorProperty.getPossibleValues();
OntologyProperty ontologyProperty = ontologyRepository.getPropertyByIRI(property.getName(), workspaceId); checkNotNull(ontologyProperty, "Could not find ontology property " + property.getName()); boolean userVisible = ontologyProperty.getUserVisible();
userVisible = false; } else { OntologyProperty ontologyProperty = ontologyRepository.getPropertyByIRI(property.getName(), workspaceId); checkNotNull( ontologyProperty,
private void doTestPublishPropertyAdd(String propertyName, String expectedError, SandboxStatus expectedEdgeStatus) { User systemUser = getUserRepository().getSystemUser(); Authorizations systemAuthorizations = getAuthorizationRepository().getGraphAuthorizations(systemUser); Vertex vertex = getGraphRepository().addVertex("v1", JUNIT_CONCEPT_TYPE, "", null, null, null, systemUser, systemAuthorizations); getWorkspaceRepository().updateEntityOnWorkspace(workspace, vertex.getId(), user); String propertyKey = "junit"; VisibilityAndElementMutation<Vertex> setPropertyMutation = getGraphRepository().setProperty(vertex, propertyName, propertyKey, "new value", new Metadata(), "", "", workspace.getWorkspaceId(), null, null, user, workspaceAuthorizations); setPropertyMutation.elementMutation.save(workspaceAuthorizations); ClientApiPropertyPublishItem publishItem = new ClientApiPropertyPublishItem(); publishItem.setVertexId(vertex.getId()); publishItem.setName(propertyName); publishItem.setKey(propertyKey); publishItem.setAction(ClientApiPublishItem.Action.ADD_OR_UPDATE); ClientApiWorkspacePublishResponse response = getWorkspaceRepository().publish(new ClientApiPublishItem[]{publishItem}, user, workspace.getWorkspaceId(), workspaceAuthorizations); Property property = getGraph().getVertex(vertex.getId(), workspaceAuthorizations).getProperty(propertyKey, propertyName); if (expectedError != null) { assertPublishFailure(response, workspace, property, expectedError); } else { assertPublishSuccess(response, workspace, property); } if (expectedEdgeStatus != null) { OntologyProperty ontologyProperty = getOntologyRepository().getPropertyByIRI(propertyName, workspace.getWorkspaceId()); assertEquals(expectedEdgeStatus, ontologyProperty.getSandboxStatus()); } }