当前位置: 首页>>代码示例>>Java>>正文


Java Penalty类代码示例

本文整理汇总了Java中eu.atos.sla.datamodel.bean.Penalty的典型用法代码示例。如果您正苦于以下问题:Java Penalty类的具体用法?Java Penalty怎么用?Java Penalty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Penalty类属于eu.atos.sla.datamodel.bean包,在下文中一共展示了Penalty类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getById

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Test
public void getById() {

	Date dateTime = new Date();
	
	IPenaltyDefinition def = new PenaltyDefinition(1, "euro", "100");
	savePenaltyDefinition(def);
	IViolation violation = new Violation();
	violationDao.save(violation);
	
	Penalty expected = new Penalty("agreement-id", dateTime, "kpiname", def, violation);

	IPenalty saved = penaltyDao.save(expected);

	IPenalty actual = penaltyDao.getById(saved.getId());

	/*
	 * All these should succeed, as expected and actual are the same object after save()
	 */
	assertEquals(expected.getAgreementId(), actual.getAgreementId());
	assertEquals(expected.getDatetime().getTime(), actual.getDatetime().getTime());
	assertEquals(expected.getKpiName(), actual.getKpiName());
	assertEquals(expected.getUuid(), actual.getUuid());

	Assert.assertTrue(expected == actual);
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:27,代码来源:PenaltyDAOJpaTest.java

示例2: getById

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Test
public void getById() {

    Date dateTime = new Date();
    
    IPenaltyDefinition def = new PenaltyDefinition(1, "euro", "100");
    savePenaltyDefinition(def);
    IViolation violation = new Violation();
    violationDao.save(violation);
    
    Penalty expected = new Penalty("agreement-id", dateTime, "kpiname", def, violation);

    IPenalty saved = penaltyDao.save(expected);

    IPenalty actual = penaltyDao.getById(saved.getId());

    /*
     * All these should succeed, as expected and actual are the same object after save()
     */
    assertEquals(expected.getAgreementId(), actual.getAgreementId());
    assertEquals(expected.getDatetime().getTime(), actual.getDatetime().getTime());
    assertEquals(expected.getKpiName(), actual.getKpiName());
    assertEquals(expected.getUuid(), actual.getUuid());

    Assert.assertTrue(expected == actual);
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:27,代码来源:PenaltyDAOJpaTest.java

示例3: evaluate

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<? extends ICompensation> evaluate(
		IAgreement agreement, IGuaranteeTerm term, List<IViolation> newViolations, Date now) {
	
	logger.debug("Evaluating business for {} new violations", newViolations.size());
	List<ICompensation> result = new ArrayList<ICompensation>();
	IBusinessValueList businessValues = term.getBusinessValueList();
	if (businessValues == null) {
		/*
		 * sanity check
		 */
		return Collections.emptyList();
	}
	for (IPenaltyDefinition penaltyDef : businessValues.getPenalties()) {
		if (penaltyDef.getKind() != CompensationKind.CUSTOM_PENALTY) {
			continue;
		}
		Date violationsBegin = new Date(now.getTime() - penaltyDef.getTimeInterval().getTime());
		/*
		 * TODO: violationsBegin should be max(violationsBegin, select last(penalty) where penalty.definition = def
		 */
		List<IViolation> oldViolations = 
				repository.getViolationsByTimeRange(agreement, term.getName(), violationsBegin, now);
		
		if (thereIsPenalty(penaltyDef, newViolations, oldViolations)) {
			
			IPenalty penalty = new Penalty(
					agreement.getAgreementId(),
					now,
					term.getKpiName(),
					penaltyDef, 
					getLastViolation(newViolations, oldViolations));
			result.add(penalty);
			logger.debug("Raised {}", penalty);
		}
	}
	return result;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:39,代码来源:SimpleBusinessValuesEvaluator.java

示例4: search

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<IPenalty> search(SearchParameters params) {
	TypedQuery<IPenalty> query = entityManager.createNamedQuery(
			Penalty.Query.SEARCH,
			IPenalty.class);

	query.setParameter("agreementId", params.getAgreementId());
	query.setParameter("termName", params.getGuaranteeTermName());
	query.setParameter("begin", params.getBegin());
	query.setParameter("end", params.getEnd());
	
	List<IPenalty> penalties = query.getResultList();
	return penalties;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:15,代码来源:PenaltyDAOJpa.java

示例5: serialize

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
/**
 * Quick and easy serialization from a model compensation to a jaxb compensation
 * @param compensation model compensation to serialize from
 * @return corresponding jaxb object
 */
private Object serialize(ICompensation compensation) {
	Object result;
	if (compensation instanceof Penalty) {
		result = new eu.atos.sla.parser.data.Penalty((Penalty)compensation);
	}
	else {
		throw new UnsupportedOperationException("Not implemented");
	}
	return result;
}
 
开发者ID:modaclouds,项目名称:modaclouds-sla-core,代码行数:16,代码来源:RestNotifier.java

示例6: testOnFinishEvaluation

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Test
public void testOnFinishEvaluation() {
	IAgreement agreement = new eu.atos.sla.datamodel.bean.Agreement();
	agreement.setAgreementId("agreement-id");
	IGuaranteeTerm term = new GuaranteeTerm();
	term.setKpiName("kpi");
	term.setName("TERM");
	GuaranteeTermEvaluationResult res = new GuaranteeTermEvaluationResult(
			Collections.<IViolation>emptyList(), 
			Arrays.asList(
					new Penalty(agreement.getAgreementId(), 
								new Date(),
								term.getKpiName(),
								new PenaltyDefinition(1, new Date(60000), "discount", "euro", "100", "P1M"),
								new Violation(agreement, term, null, "", "", new Date())
					)
			)
	);
	Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> map = 
			new HashMap<IGuaranteeTerm, GuaranteeTermEvaluationResult>();
	
	map.put(term, res);
	
	try {
		notifier.onFinishEvaluation(agreement, map);
		assertTrue(true);
	} catch (RestNotifierException e) {
		fail("Failed with status " + e.getStatus());
	}
}
 
开发者ID:modaclouds,项目名称:modaclouds-sla-core,代码行数:31,代码来源:RestNotifierTest.java

示例7: evaluate

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<? extends ICompensation> evaluate(
        IAgreement agreement, IGuaranteeTerm term, List<IViolation> newViolations, Date now) {
    
    logger.debug("Evaluating business for {} new violations", newViolations.size());
    List<ICompensation> result = new ArrayList<ICompensation>();
    IBusinessValueList businessValues = term.getBusinessValueList();
    if (businessValues == null) {
        /*
         * sanity check
         */
        return Collections.emptyList();
    }
    for (IPenaltyDefinition penaltyDef : businessValues.getPenalties()) {
        if (penaltyDef.getKind() != CompensationKind.CUSTOM_PENALTY) {
            continue;
        }
        Date violationsBegin = new Date(now.getTime() - penaltyDef.getTimeInterval().getTime());
        /*
         * TODO: violationsBegin should be max(violationsBegin, select last(penalty) where penalty.definition = def
         */
        List<IViolation> oldViolations = 
                repository.getViolationsByTimeRange(agreement, term.getName(), violationsBegin, now);
        
        if (thereIsPenalty(penaltyDef, newViolations, oldViolations)) {
            
            IPenalty penalty = new Penalty(
                    agreement.getAgreementId(),
                    now,
                    term.getKpiName(),
                    penaltyDef, 
                    getLastViolation(newViolations, oldViolations));
            result.add(penalty);
            logger.debug("Raised {}", penalty);
        }
    }
    return result;
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:39,代码来源:SimpleBusinessValuesEvaluator.java

示例8: search

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<IPenalty> search(SearchParameters params) {
    TypedQuery<IPenalty> query = entityManager.createNamedQuery(
            Penalty.Query.SEARCH,
            IPenalty.class);

    query.setParameter("agreementId", params.getAgreementId());
    query.setParameter("termName", params.getGuaranteeTermName());
    query.setParameter("begin", params.getBegin());
    query.setParameter("end", params.getEnd());
    
    List<IPenalty> penalties = query.getResultList();
    return penalties;
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:15,代码来源:PenaltyDAOJpa.java

示例9: getById

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public Penalty getById(Long id) {
	return entityManager.find(Penalty.class, id);
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:5,代码来源:PenaltyDAOJpa.java

示例10: getById

import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public Penalty getById(Long id) {
    return entityManager.find(Penalty.class, id);
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:5,代码来源:PenaltyDAOJpa.java


注:本文中的eu.atos.sla.datamodel.bean.Penalty类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。