Search in sources :

Example 1 with ExtensibleEntity

use of com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity in project kylo by Teradata.

the class FeedSlaUpgradeAction method upgradeFeedSla.

private void upgradeFeedSla(ExtensibleType type) {
    List<ExtensibleEntity> slaRels = entityProvider.getEntities(SLA_REL_TYPE_NAME);
    for (ExtensibleEntity rel : slaRels) {
        ServiceLevelAgreement sla = JcrUtil.getJcrObject(rel.getProperty("sla"), JcrServiceLevelAgreement.class);
        Set<Feed> feeds = rel.getPropertyAsSet("feeds", Node.class).stream().map(JcrFeed::new).collect(Collectors.toSet());
        feedSlaProvider.relateFeeds(sla, feeds);
        entityProvider.deleteEntity(rel.getId());
    }
    this.typeProvider.deleteType(type.getId());
}
Also used : Node(javax.jcr.Node) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)

Example 2 with ExtensibleEntity

use of com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity in project kylo by Teradata.

the class FeedSlaUpgradeAction method upgradeFeedSla.

private void upgradeFeedSla(ExtensibleType type) {
    List<ExtensibleEntity> slaRels = entityProvider.getEntities(SLA_REL_TYPE_NAME);
    for (ExtensibleEntity rel : slaRels) {
        ServiceLevelAgreement sla = JcrUtil.getJcrObject(rel.getProperty("sla"), JcrServiceLevelAgreement.class);
        Set<Feed> feeds = rel.getPropertySet("feeds", Node.class).stream().map(JcrFeed::new).collect(Collectors.toSet());
        feedSlaProvider.relateFeeds(sla, feeds);
        entityProvider.deleteEntity(rel.getId());
    }
}
Also used : Node(javax.jcr.Node) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)

Example 3 with ExtensibleEntity

use of com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity in project kylo by Teradata.

the class JcrExtensibleProvidersTest method testGetEntity.

@Test(dependsOnMethods = "testCreatePersonType")
public void testGetEntity() {
    String typeName = metadata.commit(() -> {
        List<ExtensibleEntity> list = entityProvider.getEntities();
        assertThat(list).isNotNull().hasSize(1);
        ExtensibleEntity.ID id = list.get(0).getId();
        ExtensibleEntity entity = entityProvider.getEntity(id);
        assertThat(entity).isNotNull();
        assertThat(entity.<String>getProperty("name")).isEqualTo("Bob");
        return entity.getTypeName();
    }, MetadataAccess.SERVICE);
    assertThat(typeName).isEqualTo("Person");
}
Also used : ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with ExtensibleEntity

use of com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity in project kylo by Teradata.

the class JcrExtensibleProvidersTest method testCreateEntity.

@Test(dependsOnMethods = "testCreatePersonType")
public void testCreateEntity() {
    ExtensibleEntity.ID id = metadata.commit(() -> {
        ExtensibleType type = typeProvider.getType("Person");
        Map<String, Object> props = new HashMap<>();
        props.put("name", "Bob");
        props.put("description", "Silly");
        props.put("age", 50);
        ExtensibleEntity entity = entityProvider.createEntity(type, props);
        return entity.getId();
    }, MetadataAccess.SERVICE);
    assertThat(id).isNotNull();
}
Also used : HashMap(java.util.HashMap) ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) ExtensibleType(com.thinkbiganalytics.metadata.api.extension.ExtensibleType) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with ExtensibleEntity

use of com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity in project kylo by Teradata.

the class JcrExtensibleEntityProvider method getEntities.

@Override
public List<ExtensibleEntity> getEntities() {
    List<ExtensibleEntity> list = new ArrayList<>();
    Session session = getSession();
    try {
        String path = EntityUtil.pathForExtensibleEntity();
        Node genericsNode = session.getNode(path);
        NodeIterator typeNameItr = genericsNode.getNodes();
        while (typeNameItr.hasNext()) {
            Node typeNameNode = (Node) typeNameItr.next();
            NodeIterator entityItr = typeNameNode.getNodes();
            while (entityItr.hasNext()) {
                Node entNode = (Node) entityItr.next();
                list.add(new JcrExtensibleEntity(entNode));
            }
        }
        return list;
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve list of extensible entities", e);
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) Session(javax.jcr.Session)

Aggregations

ExtensibleEntity (com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity)6 Node (javax.jcr.Node)4 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)2 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)2 JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)2 JcrServiceLevelAgreement (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement)2 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)2 ArrayList (java.util.ArrayList)2 NodeIterator (javax.jcr.NodeIterator)2 RepositoryException (javax.jcr.RepositoryException)2 Session (javax.jcr.Session)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Test (org.testng.annotations.Test)2 ExtensibleType (com.thinkbiganalytics.metadata.api.extension.ExtensibleType)1 HashMap (java.util.HashMap)1