use of org.kuali.rice.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.
the class CuAutoDisapproveDocumentsServiceImpl method buildSuccessMessage.
private String buildSuccessMessage(Document document) throws Exception {
StringBuilder headerBuilder = new StringBuilder();
headerBuilder.append(document.getDocumentNumber());
headerBuilder.append(TAB);
headerBuilder.append(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
headerBuilder.append(TAB);
headerBuilder.append(document.getDocumentHeader().getDocumentDescription());
headerBuilder.append(TAB);
headerBuilder.append(personService.getPerson(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId()).getPrincipalName());
headerBuilder.append(TAB);
headerBuilder.append(personService.getPerson(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId()).getName());
headerBuilder.append(TAB);
headerBuilder.append(document.getDocumentHeader().getWorkflowDocument().getDateCreated());
headerBuilder.append(TAB);
ConfigurationService k = KRADServiceLocator.getKualiConfigurationService();
StringBuilder routeBuilder = new StringBuilder();
String url = k.getPropertyValueAsString("workflow.url");
routeBuilder.append(url);
routeBuilder.append("/RouteLog.do?routeHeaderId=");
routeBuilder.append(document.getDocumentNumber());
routeBuilder.append(TAB);
headerBuilder.append(routeBuilder);
List<ActionTaken> actions;
// try {
// actions = KEWServiceLocator.getActionTakenService().findByDocumentId(document.getDocumentHeader().getWorkflowDocument().getDocumentId());
actions = KewApiServiceLocator.getWorkflowDocumentService().getAllActionsTaken(document.getDocumentNumber());
ActionTaken max = null;
for (ActionTaken at : actions) {
if (ObjectUtils.isNull(max)) {
max = at;
} else if (at.getActionDate().compareTo(max.getActionDate()) > 0) {
max = at;
}
}
headerBuilder.append(personService.getPerson(max.getPrincipalId()).getPrincipalName());
headerBuilder.append(TAB);
headerBuilder.append(personService.getPerson(max.getPrincipalId()).getName());
headerBuilder.append(TAB);
headerBuilder.append(max.getActionDate());
headerBuilder.append(TAB);
headerBuilder.append(max.getActionTaken().getLabel());
headerBuilder.append(TAB);
// } catch (WorkflowException e) {
// e.printStackTrace();
// }
String headerString = headerBuilder.toString();
StringBuilder builder = new StringBuilder();
if (document instanceof AccountingDocumentBase) {
for (Object o : ((AccountingDocumentBase) document).getSourceAccountingLines()) {
SourceAccountingLine sal = (SourceAccountingLine) o;
builder.append(headerString);
builder.append(sal.getChartOfAccountsCode());
builder.append(TAB);
builder.append(sal.getAccountNumber());
builder.append(TAB);
builder.append(sal.getAmount());
builder.append(TAB);
builder.append(sal.getAccount().getOrganizationCode());
builder.append(TAB);
builder.append(KFSConstants.NEWLINE);
}
for (Object o : ((AccountingDocumentBase) document).getTargetAccountingLines()) {
TargetAccountingLine tal = (TargetAccountingLine) o;
builder.append(headerString);
builder.append(tal.getChartOfAccountsCode());
builder.append(TAB);
builder.append(tal.getAccountNumber());
builder.append(TAB);
builder.append(tal.getAmount());
builder.append(TAB);
builder.append(tal.getAccount().getOrganizationCode());
builder.append(TAB);
builder.append(KFSConstants.NEWLINE);
}
}
return builder.toString();
}
use of org.kuali.rice.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.
the class CreateAccountingDocumentServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
ConfigurationService configurationService = buildMockConfigurationService();
createAccountingDocumentService = new TestCreateAccountingDocumentServiceImpl(buildMockPersonService(), buildAccountingXmlDocumentDownloadAttachmentService(), configurationService);
createAccountingDocumentService.initializeDocumentGeneratorsFromMappings(AccountingDocumentMapping.DI_DOCUMENT, AccountingDocumentMapping.IB_DOCUMENT);
createAccountingDocumentService.setAccountingDocumentBatchInputFileType(buildAccountingXmlDocumentInputFileType());
createAccountingDocumentService.setBatchInputFileService(new BatchInputFileServiceImpl());
createAccountingDocumentService.setFileStorageService(buildFileStorageService());
createAccountingDocumentService.setConfigurationService(configurationService);
createAccountingDocumentService.setDocumentService(buildMockDocumentService());
createAccountingDocumentService.setCreateAccountingDocumentReportService(new TestCreateAccountingDocumentReportService());
createAccountingDocumentService.setParameterService(buildParameterService());
routedAccountingDocuments = new ArrayList<>();
creationOrderedBaseFileNames = new ArrayList<>();
createTargetTestDirectory();
}
use of org.kuali.rice.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.
the class CuBatchFileUtils method retrieveBatchFileStagingRootDirectories.
public static List<File> retrieveBatchFileStagingRootDirectories() {
ConfigurationService kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
List<File> directories = new ArrayList<File>();
String configProperty = kualiConfigurationService.getPropertyValueAsString(KFSConstants.STAGING_DIRECTORY_KEY);
String[] directoryNames = StringUtils.split(configProperty, ";");
for (String directoryName : directoryNames) {
File rootDirectory = new File(directoryName).getAbsoluteFile();
directories.add(rootDirectory);
}
// resolvePathToAbsolutePath methods
for (int i = 0; i < directories.size(); i++) {
for (int j = i + 1; j < directories.size(); j++) {
File directoryI = directories.get(i);
File directoryJ = directories.get(j);
if (isPrefixOfAnother(directoryI.getAbsolutePath(), directoryJ.getAbsolutePath())) {
throw new RuntimeException("Cannot have any two directories in config property batch.file.lookup.root.directories that have absolute paths that are prefix of another");
}
if (isPrefixOfAnother(directoryI.getName(), directoryJ.getName())) {
throw new RuntimeException("Cannot have any two directories in config property batch.file.lookup.root.directories that have names that are prefix of another");
}
}
}
return directories;
}
use of org.kuali.rice.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.
the class CreateDoneKualiBatchFileAdminAction method createDoneFile.
/**
* Creates a '.done' file with the name of the original file.
*/
protected String createDoneFile(String filename) {
String status = null;
String doneFileName = StringUtils.substringBeforeLast(filename, ".") + ".done";
File doneFile = new File(doneFileName);
ConfigurationService kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
if (!doneFile.exists()) {
boolean doneFileCreated = false;
try {
doneFileCreated = doneFile.createNewFile();
status = kualiConfigurationService.getPropertyValueAsString(CUKFSKeyConstants.MESSAGE_DONE_FILE_SUCCESSFULLY_CREATED);
} catch (IOException e) {
throw new RuntimeException("Errors encountered while saving the file: Unable to create .done file " + doneFileName, e);
}
if (!doneFileCreated) {
throw new RuntimeException("Errors encountered while saving the file: Unable to create .done file " + doneFileName);
}
} else {
status = kualiConfigurationService.getPropertyValueAsString(CUKFSKeyConstants.MESSAGE_DONE_FILE_ALREADY_EXISTS);
}
return status;
}
use of org.kuali.rice.core.api.config.property.ConfigurationService in project cu-kfs by CU-CommunityApps.
the class CreateAccountingDocumentServiceImplTest method buildMockConfigurationService.
private ConfigurationService buildMockConfigurationService() throws Exception {
ConfigurationService configurationService = EasyMock.createMock(ConfigurationService.class);
EasyMock.expect(configurationService.getPropertyValueAsString(CuFPTestConstants.TEST_VALIDATION_ERROR_KEY)).andStubReturn(CuFPTestConstants.TEST_VALIDATION_ERROR_MESSAGE);
EasyMock.expect(configurationService.getPropertyValueAsString(CuFPKeyConstants.ERROR_CREATE_ACCOUNTING_DOCUMENT_ATTACHMENT_DOWNLOAD)).andStubReturn(CuFPTestConstants.TEST_ATTACHMENT_DOWNLOAD_FAILURE_MESSAGE);
EasyMock.replay(configurationService);
return configurationService;
}
Aggregations