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++;
}
}
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());
}
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);
}
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());
}
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++;
}
}
}
Aggregations