Examples of LumifyApi


Examples of io.lumify.web.clientapi.LumifyApi

    }

    private void assertRawRoute() throws ApiException, IOException {
        byte[] expected = IOUtils.toByteArray(UploadImageFileIntegrationTest.class.getResourceAsStream("/io/lumify/it/sampleImage.jpg"));

        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);

        byte[] found = IOUtils.toByteArray(lumifyApi.getVertexApi().getRaw(artifactVertexId));
        assertArrayEquals(expected, found);

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        lumifyApi.logout();
    }

    private void assertThumbnailRoute() throws ApiException, IOException {
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);

        InputStream in = lumifyApi.getVertexApi().getThumbnail(artifactVertexId, 100);
        BufferedImage img = ImageIO.read(in);
        assertEquals(53, img.getWidth());
        assertEquals(100, img.getHeight());

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        lumifyApi.logout();
    }

    private void resolveAndUnresolveDetectedObject() throws ApiException {
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth1");

        ClientApiDetectedObjects detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
        LOGGER.info("detectedObjects: %s", detectedObjects.toString());
        assertEquals(15, detectedObjects.getDetectedObjects().size());

        // Resolving a new detected object
        double x1 = 1.0;
        double x2 = 2.0;
        double y1 = 3.0;
        double y2 = 4.0;
        lumifyApi.getVertexApi().resolveDetectedObject(
                artifactVertexId,
                "Susan",
                CONCEPT_TEST_PERSON,
                "auth1",
                null,
                null,
                null,
                null,
                x1,
                x2,
                y1,
                y2
        );

        detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
        assertEquals(16, detectedObjects.getDetectedObjects().size());
        ClientApiProperty susanDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
        assertNotNull(susanDetectedObject);

        // Unresolving a detected object not found by opencv
        lumifyApi.getVertexApi().unresolveDetectedObject(artifactVertexId, susanDetectedObject.getKey());
        detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
        assertEquals(15, detectedObjects.getDetectedObjects().size());
        susanDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
        assertNull(susanDetectedObject);

        // Resolving a detected object that opencv found
        ClientApiDetectedObject testDetectedObjectValue = ClientApiDetectedObject.fromProperty(detectedObjects.getDetectedObjects().get(0));
        x1 = testDetectedObjectValue.getX1();
        x2 = testDetectedObjectValue.getX2();
        y1 = testDetectedObjectValue.getY1();
        y2 = testDetectedObjectValue.getY2();
        lumifyApi.getVertexApi().resolveDetectedObject(
                artifactVertexId,
                "Joe",
                CONCEPT_TEST_PERSON,
                "auth1",
                null,
                null,
                null,
                testDetectedObjectValue.getOriginalPropertyKey(),
                x1,
                x2,
                y1,
                y2
        );
        detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
        assertEquals(16, detectedObjects.getDetectedObjects().size());
        ClientApiProperty joeDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
        assertNotNull(joeDetectedObject);

        // Re-resolve a detected object
        lumifyApi.getVertexApi().resolveDetectedObject(
                artifactVertexId,
                "Jeff",
                CONCEPT_TEST_PERSON,
                "auth1",
                ClientApiDetectedObject.fromProperty(joeDetectedObject).getResolvedVertexId(),
                null,
                null,
                testDetectedObjectValue.getOriginalPropertyKey(),
                x1,
                x2,
                y1,
                y2
        );
        detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
        assertEquals(16, detectedObjects.getDetectedObjects().size());
        List<ClientApiProperty> jeffDetectedObjects = findResolvedDetectedObjects(detectedObjects, x1, x2, y1, y2);
        assertNotNull(jeffDetectedObjects);
        assertEquals(1, jeffDetectedObjects.size());

        // Unresolving a detected object that opencv found
        ClientApiProperty jeffDetectedObject = jeffDetectedObjects.get(0);
        lumifyApi.getVertexApi().unresolveDetectedObject(artifactVertexId, jeffDetectedObject.getKey());
        detectedObjects = lumifyApi.getVertexApi().getDetectedObjects(artifactVertexId, LumifyProperties.DETECTED_OBJECT.getPropertyName(), "");
        assertEquals(15, detectedObjects.getDetectedObjects().size());
        jeffDetectedObject = findResolvedDetectedObject(detectedObjects, x1, x2, y1, y2);
        assertNull(jeffDetectedObject);
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

    @Test
    public void testResolveTerm() throws IOException, ApiException {
        setupData();

        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
        resolveTerm(lumifyApi);
        assertHighlightedTextUpdatedWithResolvedEntity(lumifyApi);
        assertDiff(lumifyApi);
        lumifyApi.logout();

        lumifyApi = login(USERNAME_TEST_USER_2);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_2, "auth1");
        assertHighlightedTextDoesNotContainResolvedEntityForOtherUser(lumifyApi);
        lumifyApi.logout();

        lumifyApi = login(USERNAME_TEST_USER_1);
        assertPublishAll(lumifyApi, 2);
        lumifyTestCluster.processGraphPropertyQueue();
        lumifyApi.logout();

        lumifyApi = login(USERNAME_TEST_USER_2);
        assertHighlightedTextContainResolvedEntityForOtherUser(lumifyApi);
        lumifyApi.logout();

        lumifyApi = login(USERNAME_TEST_USER_1);
        resolveAndUnresolveTerm(lumifyApi);
        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        resolveAndUnresolveTerm(lumifyApi);
        lumifyApi.logout();
    }

    public void setupData() throws ApiException, IOException {
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth1");

        ClientApiArtifactImportResponse artifact = lumifyApi.getVertexApi().importFile("auth1", "test.txt", new ByteArrayInputStream("Joe Ferner knows David Singley.".getBytes()));
        assertEquals(1, artifact.getVertexIds().size());
        artifactVertexId = artifact.getVertexIds().get(0);
        assertNotNull(artifactVertexId);

        lumifyTestCluster.processGraphPropertyQueue();

        joeFernerVertex = lumifyApi.getVertexApi().create(CONCEPT_TEST_PERSON, "auth1");
        lumifyApi.getVertexApi().setProperty(joeFernerVertex.getId(), TEST_MULTI_VALUE_KEY, LumifyProperties.TITLE.getPropertyName(), "Joe Ferner", "auth1", "test", null, null);

        lumifyTestCluster.processGraphPropertyQueue();

        assertPublishAll(lumifyApi, 14);

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        assertUser2CanSeeRdfVertices();
        assertGetEdgesWithVisibilities();
    }

    public void uploadAndProcessRdf() throws ApiException, IOException {
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth1");
        addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth2");

        ClientApiArtifactImportResponse artifact = lumifyApi.getVertexApi().importFile("auth1", "sample.rdf", new ByteArrayInputStream(FILE_CONTENTS.getBytes()));
        artifactVertexId = artifact.getVertexIds().get(0);

        lumifyTestCluster.processGraphPropertyQueue();

        assertPublishAll(lumifyApi, 25);

        ClientApiVertexSearchResponse searchResults = lumifyApi.getVertexApi().vertexSearch("*");
        LOGGER.info("searchResults (user1): %s", searchResults);
        assertEquals(4, searchResults.getVertices().size());
        for (ClientApiVertex v : searchResults.getVertices()) {
            assertEquals("auth1", v.getVisibilitySource());

            if (v.getId().equals("PERSON_Joe_Ferner")) {
                joeFernerVertexId = v.getId();
            }
            if (v.getId().equals("PERSON_Dave_Singley")) {
                daveSingleyVertexId = v.getId();
            }
            if (v.getId().equals("COMPANY_Altamira_Corporation")) {
                altamiraCorporationVertexId = v.getId();
            }
        }
        assertNotNull(joeFernerVertexId, "Could not find joe ferner");
        assertNotNull(daveSingleyVertexId, "Could not find dave singley");

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        lumifyApi.logout();
    }

    private void assertUser2CanSeeRdfVertices() throws ApiException {
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_2);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_2, "auth1");

        assertSearch(lumifyApi);
        assertGetEdges(lumifyApi);
        assertFindPath(lumifyApi);
        assertFindRelated(lumifyApi);
        assertFindMultiple(lumifyApi);
        assertWorkspace(lumifyApi);

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

    private void assertGetEdgesWithVisibilities() throws ApiException {
        int existingEdgeCount = 0;
        long existingEdgeTotalCount = 0;
        String altamiraCorporationVertexId = null;

        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);

        ClientApiVertexSearchResponse vertices = lumifyApi.getVertexApi().vertexSearch("*");
        boolean foundAndChangedVertexVisibility = false;
        for (ClientApiVertex v : vertices.getVertices()) {
            if (v.getId().contains("PERSON_Joe_Ferner")) {
                lumifyApi.getVertexApi().setVisibility(v.getId(), "auth2");
                foundAndChangedVertexVisibility = true;
            } else if (v.getId().contains("COMPANY_Altamira_Corporation")) {
                altamiraCorporationVertexId = v.getId();
                ClientApiVertexEdges existingEdges = lumifyApi.getVertexApi().getEdges(altamiraCorporationVertexId, null, 0, 100);
                existingEdgeCount = existingEdges.getRelationships().size();
                existingEdgeTotalCount = existingEdges.getTotalReferences();
            }
        }
        assertTrue(foundAndChangedVertexVisibility, "could not find or change vertex visibility");
        assertNotNull("altamiraCorporationVertexId was null", altamiraCorporationVertexId);
        assertEquals(3, existingEdgeCount);
        assertEquals(3, existingEdgeTotalCount);

        lumifyApi.logout();

        lumifyApi = login(USERNAME_TEST_USER_2);

        ClientApiVertexEdges existingEdges = lumifyApi.getVertexApi().getEdges(altamiraCorporationVertexId, null, 0, 100);
        assertEquals(2, existingEdges.getRelationships().size());
        assertEquals(2, existingEdges.getTotalReferences());

        existingEdges = lumifyApi.getVertexApi().getEdges(altamiraCorporationVertexId, null, 0, 1);
        assertEquals(1, existingEdges.getRelationships().size());
        assertEquals(2, existingEdges.getTotalReferences());

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        resolveTermsAsUser1();
    }

    private void importVideoAndPublishAsUser1() throws ApiException, IOException {
        LOGGER.info("importVideoAndPublishAsUser1");
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth1");

        InputStream videoResourceStream = UploadVideoFileIntegrationTest.class.getResourceAsStream("/io/lumify/it/shortVideo.mp4");
        InputStream videoTranscriptResourceStream = UploadVideoFileIntegrationTest.class.getResourceAsStream("/io/lumify/it/shortVideo.mp4.srt");
        ClientApiArtifactImportResponse artifact = lumifyApi.getVertexApi().importFiles(
                new VertexApiExt.FileForImport("auth1", "shortVideo.mp4", videoResourceStream),
                new VertexApiExt.FileForImport("auth1", "shortVideo.mp4.srt", videoTranscriptResourceStream));
        assertEquals(1, artifact.getVertexIds().size());
        artifactVertexId = artifact.getVertexIds().get(0);
        assertNotNull(artifactVertexId);

        lumifyTestCluster.processGraphPropertyQueue();

        boolean foundTesseractVideoTranscript = false;
        ClientApiElement vertex = lumifyApi.getVertexApi().getByVertexId(artifactVertexId);
        for (ClientApiProperty prop : vertex.getProperties()) {
            LOGGER.info(prop.toString());
            if (LumifyProperties.TEXT.getPropertyName().equals(prop.getName()) || MediaLumifyProperties.VIDEO_TRANSCRIPT.getPropertyName().equals(prop.getName())) {
                String highlightedText = lumifyApi.getVertexApi().getHighlightedText(artifactVertexId, prop.getKey());
                LOGGER.info("highlightedText: %s: %s: %s", prop.getName(), prop.getKey(), highlightedText);
                if (prop.getKey().equals(TesseractGraphPropertyWorker.TEXT_PROPERTY_KEY)) {
                    foundTesseractVideoTranscript = true;
                    assertTrue("invalid highlighted text for tesseract", highlightedText.contains("Test") && highlightedText.contains("12000"));
                }
            }
        }
        assertTrue("foundTesseractVideoTranscript", foundTesseractVideoTranscript);

        assertPublishAll(lumifyApi, 37);

        lumifyApi.logout();
    }
View Full Code Here

Examples of io.lumify.web.clientapi.LumifyApi

        importArtifact();
        undoAll();
    }

    private void importArtifact() throws IOException, ApiException {
        LumifyApi lumifyApi = login(USERNAME_TEST_USER_1);
        addUserAuth(lumifyApi, USERNAME_TEST_USER_1, "auth1");
        ClientApiArtifactImportResponse artifact = lumifyApi.getVertexApi().importFile("auth1", "test.txt", new ByteArrayInputStream(FILE_CONTENTS.getBytes()));
        assertEquals(1, artifact.getVertexIds().size());
        String artifactVertexId = artifact.getVertexIds().get(0);
        assertNotNull(artifactVertexId);

        lumifyTestCluster.processGraphPropertyQueue();

        ClientApiElement susanFengVertex = lumifyApi.getVertexApi().create(CONCEPT_TEST_PERSON, "");
        lumifyApi.getVertexApi().setProperty(susanFengVertex.getId(), TEST_MULTI_VALUE_KEY, LumifyProperties.TITLE.getPropertyName(), "Susan Feng", "", "test", null, null);

        ClientApiElement jeffKunkleVertex = lumifyApi.getVertexApi().create(CONCEPT_TEST_PERSON, "");
        lumifyApi.getVertexApi().setProperty(jeffKunkleVertex.getId(), TEST_MULTI_VALUE_KEY, LumifyProperties.TITLE.getPropertyName(), "Jeff Kunkle", "", "test", null, null);

        lumifyApi.getEdgeApi().create(susanFengVertex.getId(), jeffKunkleVertex.getId(), TestOntology.WORKS_FOR, "");
        ClientApiVertexEdges edges = lumifyApi.getVertexApi().getEdges(susanFengVertex.getId(), null, null, null);
        assertEquals(1, edges.getRelationships().size());

        edges = lumifyApi.getVertexApi().getEdges(artifactVertexId, null, null, null);
        assertEquals(2, edges.getRelationships().size());
        ClientApiElement restonVertex = edges.getRelationships().get(0).getVertex();
        assertHasProperty(restonVertex.getProperties(), ClavinTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.CONCEPT_TYPE.getPropertyName(), CONCEPT_TEST_CITY);
        assertHasProperty(restonVertex.getProperties(), ClavinTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.SOURCE.getPropertyName(), "CLAVIN");
        assertHasProperty(restonVertex.getProperties(), ClavinTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.TITLE.getPropertyName(), "Reston (US, VA)");
        VisibilityJson visibilityJson = new VisibilityJson();
        visibilityJson.setSource("auth1");
        visibilityJson.addWorkspace(lumifyApi.getCurrentWorkspaceId());
        assertHasProperty(restonVertex.getProperties(), ClavinTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.VISIBILITY_JSON.getPropertyName(), visibilityJson);

        ClientApiElement zipCodeVertex = edges.getRelationships().get(1).getVertex();
        assertHasProperty(zipCodeVertex.getProperties(), ZipCodeResolverTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.CONCEPT_TYPE.getPropertyName(), CONCEPT_TEST_ZIP_CODE);
        assertHasProperty(zipCodeVertex.getProperties(), ZipCodeResolverTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.SOURCE.getPropertyName(), "Zip Code Resolver");
        assertHasProperty(zipCodeVertex.getProperties(), ZipCodeResolverTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.TITLE.getPropertyName(), "20191 - Reston, VA");
        visibilityJson = new VisibilityJson();
        visibilityJson.setSource("auth1");
        visibilityJson.addWorkspace(lumifyApi.getCurrentWorkspaceId());
        assertHasProperty(zipCodeVertex.getProperties(), ZipCodeResolverTermMentionFilter.MULTI_VALUE_PROPERTY_KEY, LumifyProperties.VISIBILITY_JSON.getPropertyName(), visibilityJson);

        lumifyApi.logout();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.