Search in sources :

Example 1 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class EmrDaoImplTest method testGetMap.

@Test
public void testGetMap() {
    // Create objects required for testing.
    final String name = STRING_VALUE;
    final String value = STRING_VALUE_2;
    final Parameter parameter = new Parameter(name, value);
    // Call the method under test.
    Map<String, String> result = emrDaoImpl.getMap(Arrays.asList(parameter));
    // Verify the external calls.
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(1, CollectionUtils.size(result));
    assertTrue(result.containsKey(name));
    assertEquals(value, result.get(name));
}
Also used : Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 2 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class EmrDaoImplTest method testGetConfigurations.

@Test
public void testGetConfigurations() {
    // Create objects required for testing.
    final String classification = STRING_VALUE;
    final List<EmrClusterDefinitionConfiguration> emrClusterDefinitionConfigurations = null;
    final List<Parameter> properties = null;
    final EmrClusterDefinitionConfiguration emrClusterDefinitionConfiguration = new EmrClusterDefinitionConfiguration(classification, emrClusterDefinitionConfigurations, properties);
    // Call the method under test.
    List<Configuration> result = emrDaoImpl.getConfigurations(Arrays.asList(emrClusterDefinitionConfiguration));
    // Verify the external calls.
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    final List<Configuration> expectedConfigurations = null;
    assertEquals(Arrays.asList(new Configuration().withClassification(classification).withConfigurations(expectedConfigurations).withProperties(null)), result);
}
Also used : EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) Configuration(com.amazonaws.services.elasticmapreduce.model.Configuration) EmrClusterDefinitionEbsConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionEbsConfiguration) EbsConfiguration(com.amazonaws.services.elasticmapreduce.model.EbsConfiguration) Parameter(org.finra.herd.model.api.xml.Parameter) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 3 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobDefinitionServiceImpl method createJobDefinitionFromEntity.

/**
 * Creates the job definition from the persisted entity.
 *
 * @param jobDefinitionEntity the newly persisted job definition entity.
 *
 * @return the job definition.
 */
private JobDefinition createJobDefinitionFromEntity(JobDefinitionEntity jobDefinitionEntity) throws IOException {
    // Create the business object definition information.
    JobDefinition jobDefinition = new JobDefinition();
    jobDefinition.setId(jobDefinitionEntity.getId());
    jobDefinition.setNamespace(jobDefinitionEntity.getNamespace().getCode());
    jobDefinition.setJobName(jobDefinitionEntity.getName());
    jobDefinition.setDescription(jobDefinitionEntity.getDescription());
    String s3BucketName = jobDefinitionEntity.getS3BucketName();
    String s3ObjectKey = jobDefinitionEntity.getS3ObjectKey();
    if (s3BucketName != null && s3ObjectKey != null) {
        S3PropertiesLocation s3PropertiesLocation = new S3PropertiesLocation();
        s3PropertiesLocation.setBucketName(s3BucketName);
        s3PropertiesLocation.setKey(s3ObjectKey);
        jobDefinition.setS3PropertiesLocation(s3PropertiesLocation);
    }
    // Retrieve Activiti XML from activiti.
    ProcessDefinition processDefinition = activitiRepositoryService.createProcessDefinitionQuery().processDefinitionId(jobDefinitionEntity.getActivitiId()).singleResult();
    InputStream xmlStream = activitiRepositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
    jobDefinition.setActivitiJobXml(IOUtils.toString(xmlStream));
    // Add in the parameters.
    List<Parameter> parameters = new ArrayList<>();
    jobDefinition.setParameters(parameters);
    for (JobDefinitionParameterEntity parameterEntity : jobDefinitionEntity.getParameters()) {
        Parameter parameter = new Parameter(parameterEntity.getName(), parameterEntity.getValue());
        jobDefinitionHelper.maskPassword(parameter);
        parameters.add(parameter);
    }
    // Populate the "last updated by" user ID.
    jobDefinition.setLastUpdatedByUserId(jobDefinitionEntity.getUpdatedBy());
    return jobDefinition;
}
Also used : S3PropertiesLocation(org.finra.herd.model.api.xml.S3PropertiesLocation) InputStream(java.io.InputStream) JobDefinitionParameterEntity(org.finra.herd.model.jpa.JobDefinitionParameterEntity) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) JobDefinition(org.finra.herd.model.api.xml.JobDefinition)

Example 4 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class StorageUnitStatusChangeNotificationJobActionServiceImpl method buildJobParameters.

private List<Parameter> buildJobParameters(StorageUnitNotificationEventParamsDto storageUnitNotificationEventParams) throws IOException {
    List<Parameter> parameters = new ArrayList<>();
    BusinessObjectData businessObjectData = storageUnitNotificationEventParams.getBusinessObjectData();
    NotificationJobActionEntity notificationJobActionEntity = storageUnitNotificationEventParams.getNotificationJobAction();
    parameters.add(new Parameter(PARAM_NAMESPACE, storageUnitNotificationEventParams.getStorageUnitNotificationRegistration().getNamespace().getCode()));
    parameters.add(new Parameter(PARAM_NOTIFICATION_NAME, storageUnitNotificationEventParams.getStorageUnitNotificationRegistration().getName()));
    parameters.add(new Parameter(PARAM_STORAGE_UNIT_EVENT_TYPE, storageUnitNotificationEventParams.getEventType()));
    parameters.add(new Parameter(PARAM_CORRELATION_DATA, notificationJobActionEntity.getCorrelationData()));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA, jsonHelper.objectToJson(businessObjectData)));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAMESPACE, businessObjectData.getNamespace()));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAME, businessObjectData.getBusinessObjectDefinitionName()));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_USAGE, businessObjectData.getBusinessObjectFormatUsage()));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_FILE_TYPE, businessObjectData.getBusinessObjectFormatFileType()));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_VERSION, Integer.toString(businessObjectData.getBusinessObjectFormatVersion())));
    parameters.add(new Parameter(PARAM_PARTITION_COLUMN_NAMES, herdStringHelper.buildStringWithDefaultDelimiter(storageUnitNotificationEventParams.getPartitionColumnNames())));
    parameters.add(new Parameter(PARAM_PARTITION_VALUES, herdStringHelper.buildStringWithDefaultDelimiter(storageUnitNotificationEventParams.getPartitionValues())));
    parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA_VERSION, Integer.toString(businessObjectData.getVersion())));
    parameters.add(new Parameter(PARAM_STORAGE_NAME, storageUnitNotificationEventParams.getStorageName()));
    parameters.add(new Parameter(PARAM_NEW_STORAGE_UNIT_STATUS, storageUnitNotificationEventParams.getNewStorageUnitStatus()));
    parameters.add(new Parameter(PARAM_OLD_STORAGE_UNIT_STATUS, storageUnitNotificationEventParams.getOldStorageUnitStatus()));
    return parameters;
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) NotificationJobActionEntity(org.finra.herd.model.jpa.NotificationJobActionEntity)

Example 5 with Parameter

use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.

the class JobServiceImpl method createJobFromRequest.

/**
 * Creates a new job object from request.
 *
 * @param namespaceCd, the namespace Code
 * @param jobName, the job name
 * @param mergedParameters parameters that were submitted with the job
 * @param processInstanceId process instance ID of the submitted job
 *
 * @return the created job object
 */
private Job createJobFromRequest(String namespaceCd, String jobName, Map<String, Object> mergedParameters, String processInstanceId) {
    // Create the job.
    Job job = new Job();
    job.setId(processInstanceId);
    job.setNamespace(namespaceCd);
    job.setJobName(jobName);
    // Populate parameters from process instance.
    if (!mergedParameters.isEmpty()) {
        List<Parameter> jobParameters = new ArrayList<>();
        job.setParameters(jobParameters);
        for (Map.Entry<String, Object> entry : mergedParameters.entrySet()) {
            Parameter parameter = new Parameter(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null);
            jobDefinitionHelper.maskPassword(parameter);
            jobParameters.add(parameter);
        }
    }
    return job;
}
Also used : ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Job(org.finra.herd.model.api.xml.Job) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Parameter (org.finra.herd.model.api.xml.Parameter)148 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)98 FieldExtension (org.activiti.bpmn.model.FieldExtension)64 HashMap (java.util.HashMap)61 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)30 Job (org.finra.herd.model.api.xml.Job)30 SystemJobRunRequest (org.finra.herd.model.api.xml.SystemJobRunRequest)20 SystemJobRunResponse (org.finra.herd.model.api.xml.SystemJobRunResponse)14 S3PropertiesLocation (org.finra.herd.model.api.xml.S3PropertiesLocation)13 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)13 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 JobDefinition (org.finra.herd.model.api.xml.JobDefinition)9 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)7 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 JobAction (org.finra.herd.model.api.xml.JobAction)6 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)6 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5