Search in sources :

Example 1 with ConfigurationService

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();
}
Also used : TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) AccountingDocumentBase(org.kuali.kfs.sys.document.AccountingDocumentBase) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) ActionTaken(org.kuali.rice.kew.api.action.ActionTaken)

Example 2 with ConfigurationService

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();
}
Also used : BatchInputFileServiceImpl(org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) Before(org.junit.Before)

Example 3 with ConfigurationService

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;
}
Also used : ArrayList(java.util.ArrayList) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) File(java.io.File)

Example 4 with ConfigurationService

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;
}
Also used : ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) IOException(java.io.IOException) CreateDoneBatchFile(edu.cornell.kfs.sys.batch.CreateDoneBatchFile) File(java.io.File) BatchFile(org.kuali.kfs.sys.batch.BatchFile)

Example 5 with ConfigurationService

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;
}
Also used : ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService)

Aggregations

ConfigurationService (org.kuali.rice.core.api.config.property.ConfigurationService)6 File (java.io.File)2 CreateDoneBatchFile (edu.cornell.kfs.sys.batch.CreateDoneBatchFile)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 BatchFile (org.kuali.kfs.sys.batch.BatchFile)1 BatchInputFileServiceImpl (org.kuali.kfs.sys.batch.service.impl.BatchInputFileServiceImpl)1 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)1 TargetAccountingLine (org.kuali.kfs.sys.businessobject.TargetAccountingLine)1 AccountingDocumentBase (org.kuali.kfs.sys.document.AccountingDocumentBase)1 ActionTaken (org.kuali.rice.kew.api.action.ActionTaken)1