Search in sources :

Example 91 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method synchronizePartitionSchemasDeleteFromRepository.

@Test
public void synchronizePartitionSchemasDeleteFromRepository() throws Exception {
    try {
        spoon.rep = repository;
        when(spoon.getRepository()).thenReturn(repository);
        final String objectId = "object-id";
        final String partitionName = "partsch";
        TransMeta trans1 = createTransMeta();
        trans1.setRepository(repository);
        trans1.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        PartitionSchema part1 = createPartitionSchema(partitionName, false);
        part1.setObjectId(new StringObjectId(objectId));
        trans1.addOrReplacePartitionSchema(part1);
        spoon.delegates.trans.addTransformation(trans1);
        TransMeta trans2 = createTransMeta();
        trans2.setRepository(repository);
        trans2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        PartitionSchema part2 = createPartitionSchema(partitionName, false);
        part2.setObjectId(new StringObjectId(objectId));
        trans2.addOrReplacePartitionSchema(part2);
        spoon.delegates.trans.addTransformation(trans2);
        assertFalse(trans1.getPartitionSchemas().isEmpty());
        spoon.delegates.partitions.delPartitionSchema(trans2, part2);
        verify(repository).deletePartitionSchema(part2.getObjectId());
        assertTrue(trans1.getPartitionSchemas().isEmpty());
    } finally {
        spoon.rep = null;
        when(spoon.getRepository()).thenReturn(null);
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) TransMeta(org.pentaho.di.trans.TransMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 92 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method synchronizeSlaveServerRenameRepository.

@Test
public void synchronizeSlaveServerRenameRepository() throws Exception {
    try {
        spoon.rep = repository;
        final String objectId = "object-id";
        final String serverName = "SharedServer";
        JobMeta job1 = createJobMeta();
        job1.setRepository(repository);
        job1.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        SlaveServer server1 = createSlaveServer(serverName, false);
        server1.setObjectId(new StringObjectId(objectId));
        job1.addOrReplaceSlaveServer(server1);
        spoonDelegates.jobs.addJob(job1);
        JobMeta job2 = createJobMeta();
        job2.setRepository(repository);
        job2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        SlaveServer server2 = createSlaveServer(serverName, false);
        server2.setObjectId(new StringObjectId(objectId));
        spoonDelegates.jobs.addJob(job2);
        server2.setName(AFTER_SYNC_VALUE);
        sharedUtil.synchronizeSlaveServers(server2);
        job2.addOrReplaceSlaveServer(server2);
        assertEquals(AFTER_SYNC_VALUE, job1.getSlaveServers().get(0).getName());
    } finally {
        spoon.rep = null;
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 93 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method synchronizeSlaveServerDeleteFromRepository.

@Test
public void synchronizeSlaveServerDeleteFromRepository() throws Exception {
    try {
        spoon.rep = repository;
        when(spoon.getRepository()).thenReturn(repository);
        final String objectId = "object-id";
        final String serverName = "SharedServer";
        TransMeta trans = createTransMeta();
        trans.setRepository(repository);
        trans.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        SlaveServer server1 = createSlaveServer(serverName, false);
        server1.setObjectId(new StringObjectId(objectId));
        trans.addOrReplaceSlaveServer(server1);
        spoon.delegates.trans.addTransformation(trans);
        JobMeta job = createJobMeta();
        job.setRepository(repository);
        job.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        SlaveServer server3 = createSlaveServer(serverName, false);
        server3.setObjectId(new StringObjectId(objectId));
        job.addOrReplaceSlaveServer(server3);
        spoon.delegates.jobs.addJob(job);
        TransMeta trans2 = createTransMeta();
        trans2.setRepository(repository);
        trans2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
        SlaveServer server2 = createSlaveServer(serverName, false);
        server2.setObjectId(new StringObjectId(objectId));
        trans2.addOrReplaceSlaveServer(server2);
        spoon.delegates.trans.addTransformation(trans2);
        assertFalse(trans.getSlaveServers().isEmpty());
        assertFalse(job.getSlaveServers().isEmpty());
        spoon.delegates.slaves.delSlaveServer(trans2, server2);
        verify(repository).deleteSlave(server2.getObjectId());
        assertTrue(trans.getSlaveServers().isEmpty());
        assertTrue(job.getSlaveServers().isEmpty());
    } finally {
        spoon.rep = null;
        when(spoon.getRepository()).thenReturn(null);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 94 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class StarDomainMetaStoreUtil method saveStarDomain.

public static void saveStarDomain(IMetaStore metaStore, StarDomain starDomain) throws MetaStoreException {
    IMetaStoreElementType elementType = getStarDomainElementType(metaStore);
    IMetaStoreElement element = null;
    if (starDomain.getObjectId() != null) {
        // verify the ID!
        // 
        element = metaStore.getElement(namespace, elementType, starDomain.getObjectId().toString());
    }
    if (element == null) {
        // Create a new element
        // 
        element = metaStore.newElement();
        populateElementWithStarDomain(metaStore, starDomain, element, elementType);
        metaStore.createElement(namespace, elementType, element);
    } else {
        // Update an existing element
        // 
        populateElementWithStarDomain(metaStore, starDomain, element, elementType);
        metaStore.updateElement(namespace, elementType, starDomain.getObjectId().toString(), element);
    }
    starDomain.setObjectId(new StringObjectId(element.getId().toString()));
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 95 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class MQTTConsumerMetaTest method testReadsFromRepository.

@Test
public void testReadsFromRepository() throws Exception {
    StringObjectId stepId = new StringObjectId("stepId");
    MQTTConsumerMeta testMeta = getTestMeta();
    String xml = testMeta.getXML();
    when(rep.getStepAttributeString(stepId, "step-xml")).thenReturn(xml);
    meta.readRep(rep, metastore, stepId, emptyList());
    metaMatchesTestMetaFields(meta);
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Aggregations

StringObjectId (org.pentaho.di.repository.StringObjectId)123 KettleException (org.pentaho.di.core.exception.KettleException)49 ObjectId (org.pentaho.di.repository.ObjectId)38 Test (org.junit.Test)34 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)25 KettleFileException (org.pentaho.di.core.exception.KettleFileException)21 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)18 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)18 ArrayList (java.util.ArrayList)16 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)14 RepositoryObject (org.pentaho.di.repository.RepositoryObject)14 TransMeta (org.pentaho.di.trans.TransMeta)14 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)13 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)13 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)13 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)13 Repository (org.pentaho.di.repository.Repository)11 IOException (java.io.IOException)10 FileObject (org.apache.commons.vfs2.FileObject)10