* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client;
import com.att.eelf.configuration.EELFManager;
import org.apache.camel.Exchange;
-import org.apache.camel.Handler;
-import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
@Autowired
private CldsDao cldsDao;
- @Autowired
- private ClampProperties refProp;
/**
* Insert event using process variables.
*
* @param camelExchange
- * The Camel Exchange object containing the properties
+ * The Camel Exchange object containing the properties
+ * @param actionState
+ * The action state that is used instead of the one in exchange property
*/
- @Handler
- public void execute(Exchange camelExchange) {
+
+ public void addEvent(Exchange camelExchange, String actionState) {
String controlName = (String) camelExchange.getProperty("controlName");
String actionCd = (String) camelExchange.getProperty("actionCd");
- String actionStateCd = (String) camelExchange.getProperty("actionStateCd");
+ String actionStateCd = (actionState != null) ? actionState : CldsEvent.ACTION_STATE_COMPLETED;
+ actionStateCd = ((String) camelExchange.getProperty("actionStateCd")) != null
+ ? ((String) camelExchange.getProperty("actionStateCd"))
+ : actionStateCd;
// Flag indicate whether it is triggered by Validation Test button from
// UI
boolean isTest = (boolean) camelExchange.getProperty("isTest");
// won't really have userid here...
CldsEvent.insEvent(cldsDao, controlName, userid, actionCd, actionStateCd, camelExchange.getExchangeId());
}
- generateAutoPolicyId(camelExchange);
- }
-
- private void generateAutoPolicyId(Exchange camelExchange) {
- ModelProperties prop = ModelProperties.create(camelExchange);
- ;
- CldsModel cldsModel = CldsModel.retrieve(cldsDao, (String) camelExchange.getProperty("modelName"), false);
- cldsModel.setPropText(cldsModel.getPropText().replaceAll("AUTO_GENERATED_POLICY_ID_AT_SUBMIT",
- prop.getPolicyNameForDcaeDeploy(refProp)));
- cldsModel.save(cldsDao, (String) camelExchange.getProperty("userid"));
}
}