Commit 0a129d81 authored by George Tziavas's avatar George Tziavas Committed by Kostis Trantzas
Browse files

Resolve "Initialize the Execution State of a Measurement Collection Job during its creation"

parent 14eb039d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
.project
.classpath
/.settings
/.bpmn
 No newline at end of file
+10 −2
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public class MetricoOrchestrationService implements JavaDelegate {
            su = new ServiceUpdate();// the object to update the service
            MeasurementCollectionJob mcj = serviceOrderManager.addMeasurementCollectionJob(mcjFVO);
            if  (mcj != null){
              logger.info("Measurement Collection Job was not created.");
              logger.info("Measurement Collection Job was created.");

              serviceCharacteristic = new Characteristic();              
              serviceCharacteristic.setName( "_MT_MCJ_REFID" );
@@ -172,6 +172,14 @@ public class MetricoOrchestrationService implements JavaDelegate {
              serviceCharacteristic.setValue(val);
              su.addServiceCharacteristicItem(serviceCharacteristic);

			  MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO();
			  mcjMVO.setExecutionState(ExecutionStateType.ACKNOWLEDGED);
			  try {
				  serviceOrderManager.updateMeasurementCollectionJobById(mcj.getUuid(), mcjMVO);
			  } catch (IOException e) {
				  throw new RuntimeException(e);
			  }

            } else {
              logger.error("Measurement Collection Job was not created.");
              su.setState(ServiceStateType.TERMINATED);
+37 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import org.etsi.osl.model.nfv.ScaleDescriptor;
import org.etsi.osl.osom.serviceactions.NSActionRequestPayload;
import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob;
import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobFVO;
import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobMVO;
import org.etsi.osl.tmf.pm632.model.Organization;
import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecification;
@@ -200,6 +201,9 @@ public class ServiceOrderManager {
    @Value("${PM_MEASUREMENT_COLLECTION_JOB_ADD}")
    private String PM_MEASUREMENT_COLLECTION_JOB_ADD = "";

	@Value("${PM_MEASUREMENT_COLLECTION_JOB_UPDATE}")
	private String PM_MEASUREMENT_COLLECTION_JOB_UPDATE;

    
	@Transactional
	public void processOrder(ServiceOrder serviceOrder) {
@@ -1167,6 +1171,39 @@ public class ServiceOrderManager {
    return null;
}

	/**
	 * Updates a Measurement Collection Job in the database using the given Measurement Collection Job ID and update information.
	 *
	 * @param mcjId  the ID of the Measurement Collection Job to update
	 * @param mcjMVO the update information for the Measurement Collection Job
	 * @return the updated Measurement Collection Job, or null if the job could not be updated
	 */
	public MeasurementCollectionJob updateMeasurementCollectionJobById(String mcjId, MeasurementCollectionJobMVO mcjMVO) throws IOException {

		MeasurementCollectionJob measurementCollectionJob;
		logger.debug("will update MeasurementCollectionJob with id "+ mcjId+" and \nMeasurementCollectionJob.toString():\n"+ toJsonString(mcjMVO));


        try {
			Map<String, Object> map = new HashMap<>();
			map.put("mcjid", mcjId);

			Object response = template.requestBodyAndHeaders(PM_MEASUREMENT_COLLECTION_JOB_UPDATE, toJsonString(mcjMVO), map);
			logger.info("JsonUtil.toJsonString(mcjMVO): \n" + toJsonString(mcjMVO));
			if (!(response instanceof String)) {
				logger.error("MeasurementCollectionJob object is wrong.");
				return null;
			}
			measurementCollectionJob = toJsonObj((String) response, MeasurementCollectionJob.class);
			logger.info("response from PM_MEASUREMENT_COLLECTION_JOB_UPDATE: " + response);
			return measurementCollectionJob;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("Cannot update MeasurementCollectionJob with id " + mcjId + ":\n" + e.toString());
		}
		return null;
	}

  


+2 −1
Original line number Diff line number Diff line
@@ -128,3 +128,4 @@ CRD_PATCH_CR_REQ: "jms:queue:CRD.PATCH.CR_REQ"

#TMF628 ACTIONS
PM_MEASUREMENT_COLLECTION_JOB_ADD:         "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD"
PM_MEASUREMENT_COLLECTION_JOB_UPDATE:      "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.UPDATE"
 No newline at end of file