Search in sources :

Example 1 with MSLAGoal

use of org.compiere.model.MSLAGoal in project adempiere by adempiere.

the class SLACriteria method createMeasures.

/**
	 * 	Create new Measures for the Criteria
	 * 	@param criteria the criteria
	 * 	@return measures created
	 */
public int createMeasures(MSLACriteria criteria) {
    int counter = 0;
    MSLAGoal[] goals = criteria.getGoals();
    for (int i = 0; i < goals.length; i++) {
        MSLAGoal goal = goals[i];
        if (goal.isActive())
            counter += createMeasures(goal);
    }
    return counter;
}
Also used : MSLAGoal(org.compiere.model.MSLAGoal)

Example 2 with MSLAGoal

use of org.compiere.model.MSLAGoal in project adempiere by adempiere.

the class SLACriteria method calculateMeasures.

//	createMeasures
/**
	 * 	Calculate Goal Actual from unprocessed Measures of the Goal
	 * 	@param criteria SLA criteria
	 */
public void calculateMeasures(MSLACriteria criteria) {
    MSLAGoal[] goals = criteria.getGoals();
    for (int i = 0; i < goals.length; i++) {
        MSLAGoal goal = goals[i];
        if (goal.isActive()) {
            goal.setMeasureActual(calculateMeasure(goal));
            goal.setDateLastRun(new Timestamp(System.currentTimeMillis()));
            goal.saveEx();
        }
    }
}
Also used : MSLAGoal(org.compiere.model.MSLAGoal) Timestamp(java.sql.Timestamp)

Example 3 with MSLAGoal

use of org.compiere.model.MSLAGoal in project adempiere by adempiere.

the class SLAGoalProcess method doIt.

//	prepare
/**
	 * 	Process
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("PA_SLA_Goal_ID=" + p_PA_SLA_Goal_ID);
    MSLAGoal goal = new MSLAGoal(getCtx(), p_PA_SLA_Goal_ID, get_TrxName());
    if (goal.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Goal_ID@ " + p_PA_SLA_Goal_ID);
    MSLACriteria criteria = MSLACriteria.get(getCtx(), goal.getPA_SLA_Criteria_ID(), get_TrxName());
    if (criteria.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Criteria_ID@ " + goal.getPA_SLA_Criteria_ID());
    SLACriteria pgm = criteria.newInstance();
    int no = pgm.createMeasures(goal);
    //
    goal.setMeasureActual(pgm.calculateMeasure(goal));
    goal.setDateLastRun(new Timestamp(System.currentTimeMillis()));
    goal.saveEx();
    //
    return "@Created@ " + no + " - @MeasureActual@=" + goal.getMeasureActual();
}
Also used : MSLACriteria(org.compiere.model.MSLACriteria) AdempiereUserError(org.compiere.util.AdempiereUserError) MSLAGoal(org.compiere.model.MSLAGoal) MSLACriteria(org.compiere.model.MSLACriteria) Timestamp(java.sql.Timestamp)

Example 4 with MSLAGoal

use of org.compiere.model.MSLAGoal in project adempiere by adempiere.

the class SLAMeasureProcess method doIt.

//	prepare
/**
	 * 	Process
	 *	@return info
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("PA_SLA_Measure_ID=" + p_PA_SLA_Measure_ID);
    MSLAMeasure measure = new MSLAMeasure(getCtx(), p_PA_SLA_Measure_ID, get_TrxName());
    if (measure.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Measure_ID@ " + p_PA_SLA_Measure_ID);
    MSLAGoal goal = new MSLAGoal(getCtx(), measure.getPA_SLA_Goal_ID(), get_TrxName());
    if (goal.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Goal_ID@ " + measure.getPA_SLA_Goal_ID());
    MSLACriteria criteria = MSLACriteria.get(getCtx(), goal.getPA_SLA_Criteria_ID(), get_TrxName());
    if (criteria.get_ID() == 0)
        throw new AdempiereUserError("@PA_SLA_Criteria_ID@ " + goal.getPA_SLA_Criteria_ID());
    SLACriteria pgm = criteria.newInstance();
    //
    goal.setMeasureActual(pgm.calculateMeasure(goal));
    goal.setDateLastRun(new Timestamp(System.currentTimeMillis()));
    goal.saveEx();
    //
    return "@MeasureActual@=" + goal.getMeasureActual();
}
Also used : MSLACriteria(org.compiere.model.MSLACriteria) AdempiereUserError(org.compiere.util.AdempiereUserError) MSLAGoal(org.compiere.model.MSLAGoal) MSLACriteria(org.compiere.model.MSLACriteria) Timestamp(java.sql.Timestamp) MSLAMeasure(org.compiere.model.MSLAMeasure)

Aggregations

MSLAGoal (org.compiere.model.MSLAGoal)4 Timestamp (java.sql.Timestamp)3 MSLACriteria (org.compiere.model.MSLACriteria)2 AdempiereUserError (org.compiere.util.AdempiereUserError)2 MSLAMeasure (org.compiere.model.MSLAMeasure)1