Search in sources :

Example 6 with DataNodeRef

use of org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef in project pentaho-kettle by pentaho.

the class TransDelegate method saveTransformationDetails.

private void saveTransformationDetails(final DataNode rootNode, final TransMeta transMeta) throws KettleException {
    rootNode.setProperty(PROP_EXTENDED_DESCRIPTION, transMeta.getExtendedDescription());
    rootNode.setProperty(PROP_TRANS_VERSION, transMeta.getTransversion());
    rootNode.setProperty(PROP_TRANS_STATUS, transMeta.getTransstatus() < 0 ? -1L : transMeta.getTransstatus());
    rootNode.setProperty(PROP_STEP_READ, transMeta.getTransLogTable().getStepnameRead());
    rootNode.setProperty(PROP_STEP_WRITE, transMeta.getTransLogTable().getStepnameWritten());
    rootNode.setProperty(PROP_STEP_INPUT, transMeta.getTransLogTable().getStepnameInput());
    rootNode.setProperty(PROP_STEP_OUTPUT, transMeta.getTransLogTable().getStepnameOutput());
    rootNode.setProperty(PROP_STEP_UPDATE, transMeta.getTransLogTable().getStepnameUpdated());
    rootNode.setProperty(PROP_STEP_REJECTED, transMeta.getTransLogTable().getStepnameRejected());
    if (transMeta.getTransLogTable().getDatabaseMeta() != null) {
        DataNodeRef ref = new DataNodeRef(transMeta.getTransLogTable().getDatabaseMeta().getObjectId().getId());
        rootNode.setProperty(PROP_DATABASE_LOG, ref);
    }
    rootNode.setProperty(PROP_TABLE_NAME_LOG, transMeta.getTransLogTable().getTableName());
    rootNode.setProperty(PROP_USE_BATCHID, Boolean.valueOf(transMeta.getTransLogTable().isBatchIdUsed()));
    rootNode.setProperty(PROP_USE_LOGFIELD, Boolean.valueOf(transMeta.getTransLogTable().isLogFieldUsed()));
    if (transMeta.getMaxDateConnection() != null) {
        DataNodeRef ref = new DataNodeRef(transMeta.getMaxDateConnection().getObjectId().getId());
        rootNode.setProperty(PROP_ID_DATABASE_MAXDATE, ref);
    }
    rootNode.setProperty(PROP_TABLE_NAME_MAXDATE, transMeta.getMaxDateTable());
    rootNode.setProperty(PROP_FIELD_NAME_MAXDATE, transMeta.getMaxDateField());
    rootNode.setProperty(PROP_OFFSET_MAXDATE, new Double(transMeta.getMaxDateOffset()));
    rootNode.setProperty(PROP_DIFF_MAXDATE, new Double(transMeta.getMaxDateDifference()));
    rootNode.setProperty(PROP_CREATED_USER, transMeta.getCreatedUser());
    rootNode.setProperty(PROP_CREATED_DATE, transMeta.getCreatedDate());
    rootNode.setProperty(PROP_MODIFIED_USER, transMeta.getModifiedUser());
    rootNode.setProperty(PROP_MODIFIED_DATE, transMeta.getModifiedDate());
    rootNode.setProperty(PROP_SIZE_ROWSET, transMeta.getSizeRowset());
    rootNode.setProperty(PROP_UNIQUE_CONNECTIONS, transMeta.isUsingUniqueConnections());
    rootNode.setProperty(PROP_FEEDBACK_SHOWN, transMeta.isFeedbackShown());
    rootNode.setProperty(PROP_FEEDBACK_SIZE, transMeta.getFeedbackSize());
    rootNode.setProperty(PROP_USING_THREAD_PRIORITIES, transMeta.isUsingThreadPriorityManagment());
    rootNode.setProperty(PROP_SHARED_FILE, transMeta.getSharedObjectsFile());
    rootNode.setProperty(PROP_CAPTURE_STEP_PERFORMANCE, transMeta.isCapturingStepPerformanceSnapShots());
    rootNode.setProperty(PROP_STEP_PERFORMANCE_CAPTURING_DELAY, transMeta.getStepPerformanceCapturingDelay());
    rootNode.setProperty(PROP_STEP_PERFORMANCE_CAPTURING_SIZE_LIMIT, transMeta.getStepPerformanceCapturingSizeLimit());
    rootNode.setProperty(PROP_STEP_PERFORMANCE_LOG_TABLE, transMeta.getPerformanceLogTable().getTableName());
    rootNode.setProperty(PROP_LOG_SIZE_LIMIT, transMeta.getTransLogTable().getLogSizeLimit());
    rootNode.setProperty(PROP_LOG_INTERVAL, transMeta.getTransLogTable().getLogInterval());
    rootNode.setProperty(PROP_TRANSFORMATION_TYPE, transMeta.getTransformationType().getCode());
    // Save the logging tables too..
    // 
    RepositoryAttributeInterface attributeInterface = new PurRepositoryAttribute(rootNode, transMeta.getDatabases());
    for (LogTableInterface logTable : transMeta.getLogTables()) {
        logTable.saveToRepository(attributeInterface);
    }
    // Save the transformation attribute groups map
    // 
    AttributesMapUtil.saveAttributesMap(rootNode, transMeta);
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) RepositoryAttributeInterface(org.pentaho.di.repository.RepositoryAttributeInterface)

Example 7 with DataNodeRef

use of org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef in project pentaho-platform by pentaho.

the class JcrAclNodeHelper method createAclNode.

private RepositoryFile createAclNode(RepositoryFile fileToAddAclFor) {
    DataNode dataNode = new DataNode("acl node");
    DataNodeRef dataNodeRef = new DataNodeRef(fileToAddAclFor.getId());
    dataNode.setProperty(TARGET, dataNodeRef);
    dataNode.setProperty(IS_ACL_NODE, true);
    NodeRepositoryFileData nodeRepositoryFileData = new NodeRepositoryFileData(dataNode);
    return unifiedRepository.createFile(unifiedRepository.getFile("/").getId(), new RepositoryFile.Builder(UUID.randomUUID().toString()).aclNode(true).build(), nodeRepositoryFileData, "");
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 8 with DataNodeRef

use of org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryContentIT method testCreateNodeFile.

@Test
public void testCreateNodeFile() throws Exception {
    loginAsSysTenantAdmin();
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    final String expectedName = "helloworld.doesnotmatter";
    final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
    RepositoryFile parentFolder = repo.getFile(parentFolderPath);
    final String expectedPath = parentFolderPath + RepositoryFile.SEPARATOR + expectedName;
    final String serverPath = ServerRepositoryPaths.getTenantRootFolderPath() + parentFolderPath + RepositoryFile.SEPARATOR + "helloworld2.sample";
    RepositoryFile sampleFile = createSampleFile(parentFolderPath, "helloworld2.sample", "dfdd", true, 83);
    final Date EXP_DATE = new Date();
    DataNode node = new DataNode("kdjd");
    node.setProperty("ddf", "ljsdfkjsdkf");
    DataNode newChild1 = node.addNode("herfkmdx");
    newChild1.setProperty("sdfs", true);
    newChild1.setProperty("ks3", EXP_DATE);
    newChild1.setProperty("ids32", 7.32D);
    newChild1.setProperty("erere3", 9856684583L);
    newChild1.setProperty("tttss4", "843skdfj33ksaljdfj");
    newChild1.setProperty("urei2", new DataNodeRef(sampleFile.getId()));
    DataNode newChild2 = node.addNode(JcrStringHelper.fileNameEncode("pppq/qqs2"));
    newChild2.setProperty(JcrStringHelper.fileNameEncode("ttt*ss4"), "843skdfj33ksaljdfj");
    NodeRepositoryFileData data = new NodeRepositoryFileData(node);
    RepositoryFile newFile = repo.createFile(parentFolder.getId(), new RepositoryFile.Builder(expectedName).build(), data, null);
    assertNotNull(newFile.getId());
    RepositoryFile foundFile = repo.getFile(expectedPath);
    assertNotNull(foundFile);
    assertEquals(expectedName, foundFile.getName());
    DataNode foundNode = repo.getDataForRead(foundFile.getId(), NodeRepositoryFileData.class).getNode();
    assertEquals(node.getName(), foundNode.getName());
    assertNotNull(foundNode.getId());
    assertEquals(node.getProperty("ddf"), foundNode.getProperty("ddf"));
    int actualPropCount = 0;
    for (DataProperty prop : foundNode.getProperties()) {
        actualPropCount++;
    }
    assertEquals(1, actualPropCount);
    assertTrue(foundNode.hasNode("herfkmdx"));
    DataNode foundChild1 = foundNode.getNode("herfkmdx");
    assertNotNull(foundChild1.getId());
    assertEquals(newChild1.getName(), foundChild1.getName());
    assertEquals(newChild1.getProperty("sdfs"), foundChild1.getProperty("sdfs"));
    assertEquals(newChild1.getProperty("ks3"), foundChild1.getProperty("ks3"));
    assertEquals(newChild1.getProperty("ids32"), foundChild1.getProperty("ids32"));
    assertEquals(newChild1.getProperty("erere3"), foundChild1.getProperty("erere3"));
    assertEquals(newChild1.getProperty("tttss4"), foundChild1.getProperty("tttss4"));
    assertEquals(newChild1.getProperty("urei2"), foundChild1.getProperty("urei2"));
    try {
        repo.deleteFile(sampleFile.getId(), true, null);
        fail();
    } catch (UnifiedRepositoryException e) {
    // should fail due to referential integrity (newFile payload has reference to sampleFile)
    }
    actualPropCount = 0;
    for (DataProperty prop : newChild1.getProperties()) {
        actualPropCount++;
    }
    assertEquals(6, actualPropCount);
    assertTrue(foundNode.hasNode(JcrStringHelper.fileNameEncode("pppq/qqs2")));
    DataNode foundChild2 = foundNode.getNode(JcrStringHelper.fileNameEncode("pppq/qqs2"));
    assertNotNull(foundChild2.getId());
    assertEquals(newChild2.getName(), foundChild2.getName());
    assertEquals(newChild2.getProperty(JcrStringHelper.fileNameEncode("ttt:ss4")), foundChild2.getProperty(JcrStringHelper.fileNameEncode("ttt:ss4")));
    actualPropCount = 0;
    for (DataProperty prop : foundChild2.getProperties()) {
        actualPropCount++;
    }
    assertEquals(1, actualPropCount);
    // ordering
    int i = 0;
    for (DataNode currentNode : foundNode.getNodes()) {
        if (i++ == 0) {
            assertEquals(newChild1.getName(), currentNode.getName());
        } else {
            assertEquals(newChild2.getName(), currentNode.getName());
        }
    }
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) ITenant(org.pentaho.platform.api.mt.ITenant) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) UnifiedRepositoryException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) Test(org.junit.Test)

Example 9 with DataNodeRef

use of org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryContentIT method testGetReferrers.

@Test
public void testGetReferrers() throws Exception {
    loginAsSysTenantAdmin();
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    final String refereeFileName = "referee.sample";
    final String referrerFileName = "referrer.sample";
    final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
    RepositoryFile parentFolder = repo.getFile(parentFolderPath);
    RepositoryFile refereeFile = createSampleFile(parentFolderPath, refereeFileName, "dfdd", true, 83);
    DataNode node = new DataNode("kdjd");
    node.setProperty("ddf", "ljsdfkjsdkf");
    DataNode newChild1 = node.addNode("herfkmdx");
    newChild1.setProperty("urei2", new DataNodeRef(refereeFile.getId()));
    NodeRepositoryFileData data = new NodeRepositoryFileData(node);
    repo.createFile(parentFolder.getId(), new RepositoryFile.Builder(referrerFileName).build(), data, null);
    List<RepositoryFile> referrers = repo.getReferrers(refereeFile.getId());
    assertNotNull(referrers);
    assertEquals(1, referrers.size());
    assertEquals(referrers.get(0).getName(), referrerFileName);
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) ITenant(org.pentaho.platform.api.mt.ITenant) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with DataNodeRef

use of org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryContentIT method testMissingRef.

@Test
public void testMissingRef() throws Exception {
    // if a user does not have permission to a reference, it is removed from the node structure and
    // replaced with a missing link. previous releases would throw an exception.
    // create a file that suzy does not have permission to
    // create a file that suzy has permission to but references the one she doesn't
    // load the file as suzy, make sure no exceptions occur and that the node is a missing reference
    loginAsSysTenantAdmin();
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
    DataNode node = new DataNode("kdjd");
    RepositoryFile sampleFile = createSampleFile(ClientRepositoryPaths.getPublicFolderPath(), "helloworld2.sample", "dfdd", true, 83);
    RepositoryFileAcl acl = repo.getAcl(sampleFile.getId());
    RepositoryFileAcl newAcl = new RepositoryFileAcl.Builder(acl).entriesInheriting(false).clearAces().build();
    repo.updateAcl(newAcl);
    node.setProperty("urei2", new DataNodeRef(sampleFile.getId()));
    final String parentFolderPath = ClientRepositoryPaths.getPublicFolderPath();
    final String expectedName = "helloworld.doesnotmatter";
    RepositoryFile parentFolder = repo.getFile(parentFolderPath);
    assertNotNull(parentFolder);
    final String expectedPath = parentFolderPath + RepositoryFile.SEPARATOR + expectedName;
    NodeRepositoryFileData data = new NodeRepositoryFileData(node);
    RepositoryFile newFile = repo.createFile(parentFolder.getId(), new RepositoryFile.Builder(expectedName).build(), data, null);
    assertNotNull(newFile.getId());
    // now check that the ref is missing
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    RepositoryFile foundFile = repo.getFile(expectedPath);
    assertNotNull(foundFile);
    DataNode foundNode = repo.getDataForRead(newFile.getId(), NodeRepositoryFileData.class).getNode();
    DataProperty d = foundNode.getProperty("urei2");
    assertNotNull(d);
    assertTrue(d.getType() == DataPropertyType.REF);
    assertTrue(d.getRef().getId() == DataNodeRef.REF_MISSING);
    // now change permissions back so she can get access to the node, confirm things are back to normal
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    newAcl = new RepositoryFileAcl.Builder(acl).entriesInheriting(true).clearAces().build();
    repo.updateAcl(newAcl);
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    foundFile = repo.getFile(expectedPath);
    assertNotNull(foundFile);
    foundNode = repo.getDataForRead(newFile.getId(), NodeRepositoryFileData.class).getNode();
    d = foundNode.getProperty("urei2");
    assertNotNull(d);
    assertTrue(d.getType() == DataPropertyType.REF);
    assertTrue(d.getRef().getId().equals(sampleFile.getId()));
}
Also used : DataNodeRef(org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef) ITenant(org.pentaho.platform.api.mt.ITenant) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) DataProperty(org.pentaho.platform.api.repository2.unified.data.node.DataProperty) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Aggregations

DataNodeRef (org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)15 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)9 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)4 Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)3 ITenant (org.pentaho.platform.api.mt.ITenant)3 DataProperty (org.pentaho.platform.api.repository2.unified.data.node.DataProperty)3 Date (java.util.Date)2 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)2 LogTableInterface (org.pentaho.di.core.logging.LogTableInterface)2 RepositoryAttributeInterface (org.pentaho.di.repository.RepositoryAttributeInterface)2 ItemNotFoundException (javax.jcr.ItemNotFoundException)1 Node (javax.jcr.Node)1 NodeIterator (javax.jcr.NodeIterator)1 Property (javax.jcr.Property)1 PropertyIterator (javax.jcr.PropertyIterator)1 SlaveServer (org.pentaho.di.cluster.SlaveServer)1 NotePadMeta (org.pentaho.di.core.NotePadMeta)1 Repository (org.pentaho.di.repository.Repository)1