Search in sources :

Example 26 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class UnifiedRepositoryPurgeServiceTest method verifyVersionCountDeletion.

private static void verifyVersionCountDeletion(HashMap<String, List<VersionSummary>> versionListMap, IUnifiedRepository mockRepo, String fileId, int versionCount) {
    List<VersionSummary> list = versionListMap.get(fileId);
    int i = 1;
    for (VersionSummary sum : list) {
        if (i <= list.size() - versionCount) {
            verify(mockRepo, times(1)).deleteFileAtVersion(fileId, sum.getId());
        }
        i++;
    }
}
Also used : VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary)

Example 27 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class PurRepository_MoveAndRename_IT method move_DoesNotCreateRevision.

private void move_DoesNotCreateRevision(Assistant assistant) throws Exception {
    final String fileName = "move_DoesNotCreateRevision";
    AbstractMeta meta = assistant.createNew();
    assistant.save(meta, fileName, getPublicDir());
    List<VersionSummary> historyBefore = unifiedRepository.getVersionSummaries(meta.getObjectId().getId());
    purRepository.renameTransformation(meta.getObjectId(), getDirInsidePublic(fileName), null);
    List<VersionSummary> historyAfter = unifiedRepository.getVersionSummaries(meta.getObjectId().getId());
    assertEquals(historyBefore.size(), historyAfter.size());
}
Also used : AbstractMeta(org.pentaho.di.base.AbstractMeta) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary)

Example 28 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class PurRepository_Revisions_IT method testTwoRevisions_DateAndCommentAreSaved.

private void testTwoRevisions_DateAndCommentAreSaved(RepositoryElementInterface transOrJob) throws Exception {
    final String elementName = "twoRevisions_" + transOrJob.getRepositoryElementType();
    final String comment1 = "first";
    final Calendar date1 = Calendar.getInstance();
    date1.setTimeInMillis(0);
    final String comment2 = "second";
    final Calendar date2 = Calendar.getInstance();
    date2.setTimeInMillis(100);
    transOrJob.setName(elementName);
    transOrJob.setRepositoryDirectory(purRepository.getDefaultSaveDirectory(transOrJob));
    purRepository.save(transOrJob, comment1, date1, null, false);
    assertCommentAndDate(transOrJob.getObjectRevision(), date1, comment1);
    purRepository.save(transOrJob, comment2, date2, null, false);
    assertCommentAndDate(transOrJob.getObjectRevision(), date2, comment2);
    List<VersionSummary> versions = assertExistsAndGetRevisions(transOrJob);
    assertEquals(2, versions.size());
    assertCommentAndDate(versions.get(0), date1, comment1);
    assertCommentAndDate(versions.get(1), date2, comment2);
}
Also used : Calendar(java.util.Calendar) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary)

Example 29 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class PurRepository_Revisions_IT method assertExistsAndGetRevisions.

private List<VersionSummary> assertExistsAndGetRevisions(RepositoryElementInterface transOrJob) {
    ObjectId id = transOrJob.getObjectId();
    assertNotNull(id);
    RepositoryFile file = unifiedRepository.getFileById(id.toString());
    assertNotNull(file);
    return unifiedRepository.getVersionSummaries(id.toString());
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 30 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class UnifiedRepositoryPurgeService method deleteVersionsBeforeDate.

@Override
public void deleteVersionsBeforeDate(Serializable fileId, Date beforeDate) {
    List<VersionSummary> versionList = unifiedRepository.getVersionSummaries(fileId);
    int listSize = versionList.size();
    int removedCount = 0;
    for (VersionSummary versionSummary : versionList) {
        if (listSize - removedCount <= 1) {
            // Don't delete the last instance of this file.
            break;
        }
        if (versionSummary.getDate().before(beforeDate)) {
            Serializable versionId = versionSummary.getId();
            getLogger().debug("removing version " + versionId.toString());
            unifiedRepository.deleteFileAtVersion(fileId, versionId);
            removedCount++;
        }
    }
}
Also used : Serializable(java.io.Serializable) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary)

Aggregations

VersionSummary (org.pentaho.platform.api.repository2.unified.VersionSummary)32 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)18 Matchers.anyString (org.mockito.Matchers.anyString)17 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)16 List (java.util.List)12 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)9 Date (java.util.Date)7 ITenant (org.pentaho.platform.api.mt.ITenant)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)5 Serializable (java.io.Serializable)4 KettleException (org.pentaho.di.core.exception.KettleException)4 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)4 SampleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.sample.SampleRepositoryFileData)4 Calendar (java.util.Calendar)3 Node (javax.jcr.Node)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)3 KettleFileException (org.pentaho.di.core.exception.KettleFileException)3