use of org.alfresco.bm.dataload.rm.services.RecordData in project records-management by Alfresco.
the class RecordServiceTest method testAllowDuplicateState.
@Test
public void testAllowDuplicateState() {
RecordData record1 = new RecordData("test_id_1", RecordContext.IN_PLACE_RECORD, "test_name_1", "test_parentPath_1", "test_inPlacePath_1", ExecutionState.SCHEDULED);
recordService.createRecord(record1);
RecordData record2 = new RecordData("test_id_2", RecordContext.RECORD, "test_name_2", "test_parentPath_2", "test_inPlacePath_2", ExecutionState.SCHEDULED);
recordService.createRecord(record2);
doubleCheckOverwrittenMethods_notEqual(record1, record2);
}
use of org.alfresco.bm.dataload.rm.services.RecordData in project records-management by Alfresco.
the class RecordServiceTest method testRejectDuplicateRecordId.
@Test(expected = DuplicateRecordException.class)
public void testRejectDuplicateRecordId() {
String duplicateId = "test_id";
RecordData record1 = new RecordData(duplicateId, RecordContext.IN_PLACE_RECORD, "test_name_1", "test_parentPath_1", "test_inPlacePath_1", ExecutionState.SCHEDULED);
recordService.createRecord(record1);
RecordData record2 = new RecordData(duplicateId, RecordContext.RECORD, "test_name_2", "test_parentPath_2", "test_inPlacePath_2", ExecutionState.UNFILED_RECORD_DECLARED);
recordService.createRecord(record2);
doubleCheckOverwrittenMethods_notEqual(record1, record2);
}
use of org.alfresco.bm.dataload.rm.services.RecordData in project records-management by Alfresco.
the class ScheduleInPlaceRecordLoaders method preloadExistingFiles.
/**
* Helper method that iterates the hierarchy tree starting from a folder and caches the file ids
* If the path doesn't exist nothing happens
*
* @param currentNodeId
* @param relativePath
* @param eventOutputMsg
* @throws Exception
*/
private void preloadExistingFiles(String currentNodeId, String relativePath, StringBuilder eventOutputMsg) throws Exception {
boolean moreChildren;
int skipCount = 0;
do {
ContentModel currentNodeModel = new ContentModel();
currentNodeModel.setNodeRef(currentNodeId);
RestNodeModelsCollection children = restCoreAPI.withParams("where=(isPrimary=true)", "relativePath=" + relativePath, "skipCount=" + skipCount).withCoreAPI().usingNode(currentNodeModel).listChildren();
if (Integer.parseInt(restCoreAPI.getStatusCode()) == HttpStatus.SC_NOT_FOUND) {
return;
}
for (RestNodeModel child : children.getEntries()) {
if (numberOfFilesLeftToPreload() <= 0) {
// we have enough files
return;
}
if (child.onModel().getIsFile()) {
RecordData record = new RecordData(child.onModel().getId(), RecordContext.IN_PLACE_RECORD, child.onModel().getName(), null, null, ExecutionState.SCHEDULED);
unscheduledFilesCache.add(record);
} else if (!fullLoadedFolders.contains(child.onModel().getId())) {
preloadExistingFiles(child.onModel().getId(), "", eventOutputMsg);
}
}
moreChildren = children.getPagination().isHasMoreItems();
skipCount += children.getPagination().getCount();
} while (moreChildren);
// mark the folder as complete to avoid listing its children in a following iteration
fullLoadedFolders.add(currentNodeId);
}
use of org.alfresco.bm.dataload.rm.services.RecordData in project records-management by Alfresco.
the class LoadSingleComponent method fileRecordOperation.
/**
* Helper method to file the unfiled record with specified id in specified record folder.
*
* @param folder - the record folded to file unfiled record in
* @param recordId - the id of the unfiled record to be filed
* @param userModel - the user model with which the unfiled record will be filed
* @return String - the filing message
* @throws Exception
*/
private String fileRecordOperation(FolderData folder, String recordId, UserModel userModel) throws Exception {
// FileRecords records
String folderPath = folder.getPath();
String parentId = folder.getId();
RecordBodyFile recordBodyFileModel = RecordBodyFile.builder().targetParentId(parentId).build();
RecordData randomRecord = recordService.getRecord(recordId);
super.resumeTimer();
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(userModel);
recordsAPI.fileRecord(recordBodyFileModel, randomRecord.getId());
super.suspendTimer();
// Increment counts
fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
// Decrement counts for unfiled record folder or unfiled container
String unfiledParentPath = randomRecord.getParentPath();
fileFolderService.incrementFileCount(UNFILED_CONTEXT, unfiledParentPath, -1);
// change parent path to the new parent
randomRecord.setParentPath(folderPath);
randomRecord.setExecutionState(ExecutionState.RECORD_FILED);
recordService.updateRecord(randomRecord);
TimeUnit.MILLISECONDS.sleep(getDelay());
return "Filed record with id " + recordId + ".";
}
use of org.alfresco.bm.dataload.rm.services.RecordData in project records-management by Alfresco.
the class RMBaseEventProcessor method createNonElectonicRecordInUnfiledContext.
/**
* Helper method for creating specified number of non-electronic documents in specified unfiled container or unfiled record folder.
*
* @param folder - unfiled container or unfiled record folder that will contain created non-electronic document
* @param userModel - UserModel instance with wich rest api will be called
* @param nameIdentifier - a string identifier that the created non-electronic documents will start with
* @param loadFilePlanComponentDelay - delay between creation of non-electronic documents
* @throws Exception
*/
public void createNonElectonicRecordInUnfiledContext(FolderData folder, UserModel userModel, String nameIdentifier, long loadFilePlanComponentDelay) throws Exception {
String unique;
boolean isUnfiledContainer = fileFolderService.getFolder(UNFILED_CONTEXT, UNFILED_RECORD_CONTAINER_PATH).equals(folder);
String folderPath = folder.getPath();
unique = UUID.randomUUID().toString();
String newfilePlanComponentName = nameIdentifier + unique;
String newfilePlanComponentTitle = "title: " + newfilePlanComponentName;
// Build non electronic record properties
UnfiledContainerChild unfiledContainerChildModel = UnfiledContainerChild.builder().name(newfilePlanComponentName).nodeType(NON_ELECTRONIC_RECORD_TYPE).properties(UnfiledContainerChildProperties.builder().title(newfilePlanComponentTitle).description(EMPTY).build()).build();
String newRecordId;
String newRecordName;
if (isUnfiledContainer) {
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(userModel);
UnfiledContainerChild createdRecord = unfiledContainersAPI.createUnfiledContainerChild(unfiledContainerChildModel, folder.getId());
newRecordId = createdRecord.getId();
newRecordName = createdRecord.getName();
} else {
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(userModel);
UnfiledContainerChild createdRecord = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(unfiledContainerChildModel, folder.getId());
newRecordId = createdRecord.getId();
newRecordName = createdRecord.getName();
}
RecordData record = new RecordData(newRecordId, RecordContext.RECORD, newRecordName, folderPath, null, ExecutionState.UNFILED_RECORD_DECLARED);
recordService.createRecord(record);
TimeUnit.MILLISECONDS.sleep(loadFilePlanComponentDelay);
// Increment counts
fileFolderService.incrementFileCount(folder.getContext(), folderPath, 1);
}
Aggregations