@Test public void testCustomBusinessValue() throws JAXBException, FileNotFoundException, ModelConversionException { File file = getResourceFile("/samples/test_parse_business.xml"); eu.atos.sla.parser.data.wsag.Agreement agreementXML = readXml(file); IAgreement a = modelConverter.getAgreementFromAgreementXML(agreementXML, ""); IPenaltyDefinition[] expected = new IPenaltyDefinition[] { new PenaltyDefinition(1, new Date(0), "discount", "%", "35", "P1D"), new PenaltyDefinition(5, new Date(24*60*60*1000), "service", "", "sms", "P1M") }; for (IGuaranteeTerm gt : a.getGuaranteeTerms()) { int i = 0; for (IPenaltyDefinition actual : gt.getBusinessValueList().getPenalties()) { assertEquals(expected[i], actual); i++; } } }
@Override public IAgreement getAgreementFromAgreementXML( eu.atos.sla.parser.data.wsag.Agreement agreementXML, String payload) throws ModelConversionException { IAgreement agreement = new Agreement(); if (agreementXML.getAgreementId() != null) { agreement.setAgreementId(agreementXML.getAgreementId()); } Context context = agreementXML.getContext(); try { ServiceProvider ctxProvider = ServiceProvider.fromString(context.getServiceProvider()); switch (ctxProvider) { case AGREEMENT_RESPONDER: setProviderAndConsumer(agreement, context.getAgreementResponder(), context.getAgreementInitiator()); break; case AGREEMENT_INITIATOR: setProviderAndConsumer(agreement, context.getAgreementInitiator(), context.getAgreementResponder()); break; } } catch (IllegalArgumentException e) { throw new ModelConversionException("The Context/ServiceProvider field must match with the word "+ServiceProvider.AGREEMENT_RESPONDER+ " or "+ServiceProvider.AGREEMENT_INITIATOR); } if (context.getTemplateId() != null) { eu.atos.sla.datamodel.bean.Template template = new eu.atos.sla.datamodel.bean.Template(); template.setUuid(context.getTemplateId()); agreement.setTemplate(template); } if (context.getService() != null) { agreement.setServiceId(context.getService()); }else{ throw new ModelConversionException("Service is null, field must be informed"); } if (context.getExpirationTime() != null) { agreement.setExpirationDate(context.getExpirationTime()); } List<IServiceProperties> servicePropertiesList = new ArrayList<IServiceProperties>(); List<ServiceProperties> servicePropertiesListXML = agreementXML .getTerms().getAllTerms().getServiceProperties(); if (servicePropertiesListXML == null) { servicePropertiesListXML = Collections .<ServiceProperties> emptyList(); } for (ServiceProperties servicePropertiesXML : servicePropertiesListXML) { IServiceProperties serviceProperties = new eu.atos.sla.datamodel.bean.ServiceProperties(); if (servicePropertiesXML.getName() != null) { serviceProperties.setName(servicePropertiesXML.getName()); } if (servicePropertiesXML.getServiceName() != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML.getVariableSet() != null) { List<IVariable> variables = new ArrayList<IVariable>(); List<Variable> variablesXML = servicePropertiesXML.getVariableSet().getVariables(); if (variablesXML != null) { for (Variable variableXML : variablesXML) { IVariable variable = new eu.atos.sla.datamodel.bean.Variable(); logger.debug("Variable with name:{} - location:{} - metric:{}", variableXML.getName(), variableXML.getLocation(), variableXML.getMetric()); if (variableXML.getLocation() != null) { variable.setLocation(variableXML.getLocation()); } if (variableXML.getMetric() != null) { variable.setMetric(variableXML.getMetric()); } if (variableXML.getName() != null) { variable.setName(variableXML.getName()); } variables.add(variable); } serviceProperties.setVariableSet(variables); } } servicePropertiesList.add(serviceProperties); } agreement.setServiceProperties(servicePropertiesList); agreement.setName(agreementXML.getName()); List<IGuaranteeTerm> guaranteeTerms = new ArrayList<IGuaranteeTerm>(); List<GuaranteeTerm> guaranteeTermsXML = agreementXML.getTerms() .getAllTerms().getGuaranteeTerms(); if (guaranteeTermsXML == null) { guaranteeTermsXML = Collections.<GuaranteeTerm> emptyList(); } for (GuaranteeTerm guaranteeTermXML : guaranteeTermsXML) { IGuaranteeTerm guaranteeTerm = new eu.atos.sla.datamodel.bean.GuaranteeTerm(); if (guaranteeTermXML.getName() != null) { guaranteeTerm.setName(guaranteeTermXML.getName()); } ServiceScope scope = guaranteeTermXML.getServiceScope(); if (scope != null) { logger.debug("guaranteeTerm with name:{} - servicescopeName:{} - servicescopeValue:{}", guaranteeTermXML.getName(), scope.getServiceName(), scope.getValue()); guaranteeTerm.setServiceScope(scope.getValue()); guaranteeTerm.setServiceName( scope.getServiceName()); }else logger.debug("guaranteeTerm with name:{} - serviceScope is null", guaranteeTermXML.getName() ); if (guaranteeTermXML.getQualifyingCondition()!= null){ logger.debug("qualifying condition informed with:{}", guaranteeTermXML.getQualifyingCondition()); String qc = guaranteeTermXML.getQualifyingCondition(); if (qc != null) { QualifyingConditionParser.Result parsedQc = QualifyingConditionParser.parse(qc); guaranteeTerm.setSamplingPeriodFactor(parsedQc.getSamplingPeriodFactor()); if (parsedQc.getSamplingPeriodFactor() == IGuaranteeTerm.ENFORCED_AT_END) { agreement.setHasGTermToBeEvaluatedAtEndOfEnformcement(true); } } } ServiceLevelObjective slo = guaranteeTermXML.getServiceLevelObjetive(); if (slo.getKpitarget() != null) { if (slo.getKpitarget().getKpiName() != null) { guaranteeTerm.setKpiName(slo.getKpitarget().getKpiName()); String csl = slo.getKpitarget().getCustomServiceLevel(); logger.debug("guaranteeTerm with kpiname:{} -- getCustomServiceLevel: ", slo.getKpitarget().getKpiName(), csl); if (csl != null) { logger.debug("CustomServiceLevel not null"); ServiceLevelParser.Result parsedSlo = ServiceLevelParser.parse(csl); guaranteeTerm.setServiceLevel(parsedSlo.getConstraint()); }else{ logger.debug("CustomServiceLevel is null"); } } } guaranteeTerm.setBusinessValueList(businessValueListParser.parse(guaranteeTermXML)); guaranteeTerms.add(guaranteeTerm); } agreement.setGuaranteeTerms(guaranteeTerms); agreement.setText(payload); return agreement; }
ModelConversion implements IModelConverter { @Override public IAgreement getAgreementFromAgreementXML( eu.atos.sla.parser.data.wsag.Agreement agreementXML, String payload) throws ModelConversionException { IAgreement agreement = new Agreement(); if (agreementXML.getAgreementId() != null) { agreement.setAgreementId(agreementXML.getAgreementId()); } Context context = agreementXML.getContext(); try { ServiceProvider ctxProvider = ServiceProvider.fromString(context.getServiceProvider()); switch (ctxProvider) { case AGREEMENT_RESPONDER: setProviderAndConsumer(agreement, context.getAgreementResponder(), context.getAgreementInitiator()); break; case AGREEMENT_INITIATOR: setProviderAndConsumer(agreement, context.getAgreementInitiator(), context.getAgreementResponder()); break; } } catch (IllegalArgumentException e) { throw new ModelConversionException("The Context/ServiceProvider field must match with the word "+ServiceProvider.AGREEMENT_RESPONDER+ " or "+ServiceProvider.AGREEMENT_INITIATOR); } if (context.getTemplateId() != null) { eu.atos.sla.datamodel.bean.Template template = new eu.atos.sla.datamodel.bean.Template(); template.setUuid(context.getTemplateId()); agreement.setTemplate(template); } if (context.getService() != null) { agreement.setServiceId(context.getService()); }else{ throw new ModelConversionException("Service is null, field must be informed"); } if (context.getExpirationTime() != null) { agreement.setExpirationDate(context.getExpirationTime()); } List<IServiceProperties> servicePropertiesList = new ArrayList<IServiceProperties>(); List<ServiceProperties> servicePropertiesListXML = agreementXML .getTerms().getAllTerms().getServiceProperties(); if (servicePropertiesListXML == null) { servicePropertiesListXML = Collections .<ServiceProperties> emptyList(); } for (ServiceProperties servicePropertiesXML : servicePropertiesListXML) { IServiceProperties serviceProperties = new eu.atos.sla.datamodel.bean.ServiceProperties(); if (servicePropertiesXML.getName() != null) { serviceProperties.setName(servicePropertiesXML.getName()); } if (servicePropertiesXML.getServiceName() != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML.getVariableSet() != null) { List<IVariable> variables = new ArrayList<IVariable>(); List<Variable> variablesXML = servicePropertiesXML.getVariableSet().getVariables(); if (variablesXML != null) { for (Variable variableXML : variablesXML) { IVariable variable = new eu.atos.sla.datamodel.bean.Variable(); logger.debug("Variable with name:{} - location:{} - metric:{}", variableXML.getName(), variableXML.getLocation(), variableXML.getMetric()); if (variableXML.getLocation() != null) { variable.setLocation(variableXML.getLocation()); } if (variableXML.getMetric() != null) { variable.setMetric(variableXML.getMetric()); } if (variableXML.getName() != null) { variable.setName(variableXML.getName()); } variables.add(variable); } serviceProperties.setVariableSet(variables); } } servicePropertiesList.add(serviceProperties); } agreement.setServiceProperties(servicePropertiesList); agreement.setName(agreementXML.getName()); List<IGuaranteeTerm> guaranteeTerms = new ArrayList<IGuaranteeTerm>(); List<GuaranteeTerm> guaranteeTermsXML = agreementXML.getTerms() .getAllTerms().getGuaranteeTerms(); if (guaranteeTermsXML == null) { guaranteeTermsXML = Collections.<GuaranteeTerm> emptyList(); } for (GuaranteeTerm guaranteeTermXML : guaranteeTermsXML) { IGuaranteeTerm guaranteeTerm = new eu.atos.sla.datamodel.bean.GuaranteeTerm(); if (guaranteeTermXML.getName() != null) { guaranteeTerm.setName(guaranteeTermXML.getName()); } ServiceScope scope = guaranteeTermXML.getServiceScope(); if (scope != null) { logger.debug("guaranteeTerm with name:{} - servicescopeName:{} - servicescopeValue:{}", guaranteeTermXML.getName(), scope.getServiceName(), scope.getValue()); guaranteeTerm.setServiceScope(scope.getValue()); guaranteeTerm.setServiceName( scope.getServiceName()); }else logger.debug("guaranteeTerm with name:{} - serviceScope is null", guaranteeTermXML.getName() ); if (guaranteeTermXML.getQualifyingCondition()!= null){ logger.debug("qualifying condition informed with:{}", guaranteeTermXML.getQualifyingCondition()); String qc = guaranteeTermXML.getQualifyingCondition(); if (qc != null) { QualifyingConditionParser.Result parsedQc = QualifyingConditionParser.parse(qc); guaranteeTerm.setSamplingPeriodFactor(parsedQc.getSamplingPeriodFactor()); if (parsedQc.getSamplingPeriodFactor() == IGuaranteeTerm.ENFORCED_AT_END) { agreement.setHasGTermToBeEvaluatedAtEndOfEnformcement(true); } } } ServiceLevelObjective slo = guaranteeTermXML.getServiceLevelObjetive(); if (slo.getKpitarget() != null) { if (slo.getKpitarget().getKpiName() != null) { guaranteeTerm.setKpiName(slo.getKpitarget().getKpiName()); String csl = slo.getKpitarget().getCustomServiceLevel(); logger.debug("guaranteeTerm with kpiname:{} -- getCustomServiceLevel: ", slo.getKpitarget().getKpiName(), csl); if (csl != null) { logger.debug("CustomServiceLevel not null"); ServiceLevelParser.Result parsedSlo = ServiceLevelParser.parse(csl); guaranteeTerm.setServiceLevel(parsedSlo.getConstraint()); }else{ logger.debug("CustomServiceLevel is null"); } } } guaranteeTerm.setBusinessValueList(businessValueListParser.parse(guaranteeTermXML)); guaranteeTerms.add(guaranteeTerm); } agreement.setGuaranteeTerms(guaranteeTerms); agreement.setText(payload); return agreement; } }
ModelConversion implements IModelConverter { @Override public IAgreement getAgreementFromAgreementXML( eu.atos.sla.parser.data.wsag.Agreement agreementXML, String payload) throws ModelConversionException { IAgreement agreement = new Agreement(); if (agreementXML.getAgreementId() != null) { agreement.setAgreementId(agreementXML.getAgreementId()); } Context context = agreementXML.getContext(); try { ServiceProvider ctxProvider = ServiceProvider.fromString(context.getServiceProvider()); switch (ctxProvider) { case AGREEMENT_RESPONDER: setProviderAndConsumer(agreement, context.getAgreementResponder(), context.getAgreementInitiator()); break; case AGREEMENT_INITIATOR: setProviderAndConsumer(agreement, context.getAgreementInitiator(), context.getAgreementResponder()); break; } } catch (IllegalArgumentException e) { throw new ModelConversionException("The Context/ServiceProvider field must match with the word "+ServiceProvider.AGREEMENT_RESPONDER+ " or "+ServiceProvider.AGREEMENT_INITIATOR); } if (context.getTemplateId() != null) { eu.atos.sla.datamodel.bean.Template template = new eu.atos.sla.datamodel.bean.Template(); template.setUuid(context.getTemplateId()); agreement.setTemplate(template); } if (context.getService() != null) { agreement.setServiceId(context.getService()); }else{ throw new ModelConversionException("Service is null, field must be informed"); } if (context.getExpirationTime() != null) { agreement.setExpirationDate(context.getExpirationTime()); } List<IServiceProperties> servicePropertiesList = new ArrayList<IServiceProperties>(); List<ServiceProperties> servicePropertiesListXML = agreementXML .getTerms().getAllTerms().getServiceProperties(); if (servicePropertiesListXML == null) { servicePropertiesListXML = Collections .<ServiceProperties> emptyList(); } for (ServiceProperties servicePropertiesXML : servicePropertiesListXML) { IServiceProperties serviceProperties = new eu.atos.sla.datamodel.bean.ServiceProperties(); if (servicePropertiesXML.getName() != null) { serviceProperties.setName(servicePropertiesXML.getName()); } if (servicePropertiesXML.getServiceName() != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML.getVariableSet() != null) { List<IVariable> variables = new ArrayList<IVariable>(); List<Variable> variablesXML = servicePropertiesXML.getVariableSet().getVariables(); if (variablesXML != null) { for (Variable variableXML : variablesXML) { IVariable variable = new eu.atos.sla.datamodel.bean.Variable(); logger.debug("Variable with name:{} - location:{} - metric:{}", variableXML.getName(), variableXML.getLocation(), variableXML.getMetric()); if (variableXML.getLocation() != null) { variable.setLocation(variableXML.getLocation()); } if (variableXML.getMetric() != null) { variable.setMetric(variableXML.getMetric()); } if (variableXML.getName() != null) { variable.setName(variableXML.getName()); } variables.add(variable); } serviceProperties.setVariableSet(variables); } } servicePropertiesList.add(serviceProperties); } agreement.setServiceProperties(servicePropertiesList); agreement.setName(agreementXML.getName()); List<IGuaranteeTerm> guaranteeTerms = new ArrayList<IGuaranteeTerm>(); List<GuaranteeTerm> guaranteeTermsXML = agreementXML.getTerms() .getAllTerms().getGuaranteeTerms(); if (guaranteeTermsXML == null) { guaranteeTermsXML = Collections.<GuaranteeTerm> emptyList(); } for (GuaranteeTerm guaranteeTermXML : guaranteeTermsXML) { IGuaranteeTerm guaranteeTerm = new eu.atos.sla.datamodel.bean.GuaranteeTerm(); if (guaranteeTermXML.getName() != null) { guaranteeTerm.setName(guaranteeTermXML.getName()); } ServiceScope scope = guaranteeTermXML.getServiceScope(); if (scope != null) { logger.debug("guaranteeTerm with name:{} - servicescopeName:{} - servicescopeValue:{}", guaranteeTermXML.getName(), scope.getServiceName(), scope.getValue()); guaranteeTerm.setServiceScope(scope.getValue()); guaranteeTerm.setServiceName( scope.getServiceName()); }else logger.debug("guaranteeTerm with name:{} - serviceScope is null", guaranteeTermXML.getName() ); if (guaranteeTermXML.getQualifyingCondition()!= null){ logger.debug("qualifying condition informed with:{}", guaranteeTermXML.getQualifyingCondition()); String qc = guaranteeTermXML.getQualifyingCondition(); if (qc != null) { QualifyingConditionParser.Result parsedQc = QualifyingConditionParser.parse(qc); guaranteeTerm.setSamplingPeriodFactor(parsedQc.getSamplingPeriodFactor()); if (parsedQc.getSamplingPeriodFactor() == IGuaranteeTerm.ENFORCED_AT_END) { agreement.setHasGTermToBeEvaluatedAtEndOfEnformcement(true); } } } ServiceLevelObjective slo = guaranteeTermXML.getServiceLevelObjetive(); if (slo.getKpitarget() != null) { if (slo.getKpitarget().getKpiName() != null) { guaranteeTerm.setKpiName(slo.getKpitarget().getKpiName()); String csl = slo.getKpitarget().getCustomServiceLevel(); logger.debug("guaranteeTerm with kpiname:{} -- getCustomServiceLevel: ", slo.getKpitarget().getKpiName(), csl); if (csl != null) { logger.debug("CustomServiceLevel not null"); ServiceLevelParser.Result parsedSlo = ServiceLevelParser.parse(csl); guaranteeTerm.setServiceLevel(parsedSlo.getConstraint()); }else{ logger.debug("CustomServiceLevel is null"); } } } guaranteeTerm.setBusinessValueList(businessValueListParser.parse(guaranteeTermXML)); guaranteeTerms.add(guaranteeTerm); } agreement.setGuaranteeTerms(guaranteeTerms); agreement.setText(payload); return agreement; }  }
ModelConversion implements IModelConverter { @Override public IAgreement getAgreementFromAgreementXML( eu.atos.sla.parser.data.wsag.Agreement agreementXML, String payload) throws ModelConversionException { IAgreement agreement = new Agreement(); if (agreementXML.getAgreementId() != null) { agreement.setAgreementId(agreementXML.getAgreementId()); } Context context = agreementXML.getContext(); try { ServiceProvider ctxProvider = ServiceProvider.fromString(context.getServiceProvider()); switch (ctxProvider) { case AGREEMENT_RESPONDER: setProviderAndConsumer(agreement, context.getAgreementResponder(), context.getAgreementInitiator()); break; case AGREEMENT_INITIATOR: setProviderAndConsumer(agreement, context.getAgreementInitiator(), context.getAgreementResponder()); break; } } catch (IllegalArgumentException e) { throw new ModelConversionException("The Context/ServiceProvider field must match with the word "+ServiceProvider.AGREEMENT_RESPONDER+ " or "+ServiceProvider.AGREEMENT_INITIATOR); } if (context.getTemplateId() != null) { eu.atos.sla.datamodel.bean.Template template = new eu.atos.sla.datamodel.bean.Template(); template.setUuid(context.getTemplateId()); agreement.setTemplate(template); } if (context.getService() != null) { agreement.setServiceId(context.getService()); }else{ throw new ModelConversionException("Service is null, field must be informed"); } if (context.getExpirationTime() != null) { agreement.setExpirationDate(context.getExpirationTime()); } List<IServiceProperties> servicePropertiesList = new ArrayList<IServiceProperties>(); List<ServiceProperties> servicePropertiesListXML = agreementXML .getTerms().getAllTerms().getServiceProperties(); if (servicePropertiesListXML == null) { servicePropertiesListXML = Collections .<ServiceProperties> emptyList(); } for (ServiceProperties servicePropertiesXML : servicePropertiesListXML) { IServiceProperties serviceProperties = new eu.atos.sla.datamodel.bean.ServiceProperties(); if (servicePropertiesXML.getName() != null) { serviceProperties.setName(servicePropertiesXML.getName()); } if (servicePropertiesXML.getServiceName() != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML.getVariableSet() != null) { List<IVariable> variables = new ArrayList<IVariable>(); List<Variable> variablesXML = servicePropertiesXML.getVariableSet().getVariables(); if (variablesXML != null) { for (Variable variableXML : variablesXML) { IVariable variable = new eu.atos.sla.datamodel.bean.Variable(); logger.debug("Variable with name:{} - location:{} - metric:{}", variableXML.getName(), variableXML.getLocation(), variableXML.getMetric()); if (variableXML.getLocation() != null) { variable.setLocation(variableXML.getLocation()); } if (variableXML.getMetric() != null) { variable.setMetric(variableXML.getMetric()); } if (variableXML.getName() != null) { variable.setName(variableXML.getName()); } variables.add(variable); } serviceProperties.setVariableSet(variables); } } servicePropertiesList.add(serviceProperties); } agreement.setServiceProperties(servicePropertiesList); agreement.setName(agreementXML.getName()); List<IGuaranteeTerm> guaranteeTerms = new ArrayList<IGuaranteeTerm>(); List<GuaranteeTerm> guaranteeTermsXML = agreementXML.getTerms() .getAllTerms().getGuaranteeTerms(); if (guaranteeTermsXML == null) { guaranteeTermsXML = Collections.<GuaranteeTerm> emptyList(); } for (GuaranteeTerm guaranteeTermXML : guaranteeTermsXML) { IGuaranteeTerm guaranteeTerm = new eu.atos.sla.datamodel.bean.GuaranteeTerm(); if (guaranteeTermXML.getName() != null) { guaranteeTerm.setName(guaranteeTermXML.getName()); } ServiceScope scope = guaranteeTermXML.getServiceScope(); if (scope != null) { logger.debug("guaranteeTerm with name:{} - servicescopeName:{} - servicescopeValue:{}", guaranteeTermXML.getName(), scope.getServiceName(), scope.getValue()); guaranteeTerm.setServiceScope(scope.getValue()); guaranteeTerm.setServiceName( scope.getServiceName()); }else logger.debug("guaranteeTerm with name:{} - serviceScope is null", guaranteeTermXML.getName() ); if (guaranteeTermXML.getQualifyingCondition()!= null){ logger.debug("qualifying condition informed with:{}", guaranteeTermXML.getQualifyingCondition()); String qc = guaranteeTermXML.getQualifyingCondition(); if (qc != null) { QualifyingConditionParser.Result parsedQc = QualifyingConditionParser.parse(qc); guaranteeTerm.setSamplingPeriodFactor(parsedQc.getSamplingPeriodFactor()); if (parsedQc.getSamplingPeriodFactor() == IGuaranteeTerm.ENFORCED_AT_END) { agreement.setHasGTermToBeEvaluatedAtEndOfEnformcement(true); } } } ServiceLevelObjective slo = guaranteeTermXML.getServiceLevelObjetive(); if (slo.getKpitarget() != null) { if (slo.getKpitarget().getKpiName() != null) { guaranteeTerm.setKpiName(slo.getKpitarget().getKpiName()); String csl = slo.getKpitarget().getCustomServiceLevel(); logger.debug("guaranteeTerm with kpiname:{} -- getCustomServiceLevel: ", slo.getKpitarget().getKpiName(), csl); if (csl != null) { logger.debug("CustomServiceLevel not null"); ServiceLevelParser.Result parsedSlo = ServiceLevelParser.parse(csl); guaranteeTerm.setServiceLevel(parsedSlo.getConstraint()); }else{ logger.debug("CustomServiceLevel is null"); } } } guaranteeTerm.setBusinessValueList(businessValueListParser.parse(guaranteeTermXML)); guaranteeTerms.add(guaranteeTerm); } agreement.setGuaranteeTerms(guaranteeTerms); agreement.setText(payload); return agreement; }  @Override IAgreement getAgreementFromAgreementXML(
            eu.atos.sla.parser.data.wsag.Agreement agreementXML,
            String payload); @Override ITemplate getTemplateFromTemplateXML(eu.atos.sla.parser.data.wsag.Template templateXML,    String payload); @Override Context getContextFromAgreement(IAgreement agreement); @Override IEnforcementJob getEnforcementJobFromEnforcementJobXML(
            EnforcementJob enforcementJobXML); @Override IProvider getProviderFromProviderXML(eu.atos.sla.parser.data.Provider providerXML); @Override Provider getProviderXML(IProvider provider); @Override Violation getViolationXML(IViolation violation); @Override EnforcementJob getEnforcementJobXML(
            IEnforcementJob enforcementJob); @Override Penalty getPenaltyXML(IPenalty penalty); void setBusinessValueListParser(
            BusinessValueListParser customBusinessValueParser); }
ModelConversion implements IModelConverter { @Override public IAgreement getAgreementFromAgreementXML( eu.atos.sla.parser.data.wsag.Agreement agreementXML, String payload) throws ModelConversionException { IAgreement agreement = new Agreement(); if (agreementXML.getAgreementId() != null) { agreement.setAgreementId(agreementXML.getAgreementId()); } Context context = agreementXML.getContext(); try { ServiceProvider ctxProvider = ServiceProvider.fromString(context.getServiceProvider()); switch (ctxProvider) { case AGREEMENT_RESPONDER: setProviderAndConsumer(agreement, context.getAgreementResponder(), context.getAgreementInitiator()); break; case AGREEMENT_INITIATOR: setProviderAndConsumer(agreement, context.getAgreementInitiator(), context.getAgreementResponder()); break; } } catch (IllegalArgumentException e) { throw new ModelConversionException("The Context/ServiceProvider field must match with the word "+ServiceProvider.AGREEMENT_RESPONDER+ " or "+ServiceProvider.AGREEMENT_INITIATOR); } if (context.getTemplateId() != null) { eu.atos.sla.datamodel.bean.Template template = new eu.atos.sla.datamodel.bean.Template(); template.setUuid(context.getTemplateId()); agreement.setTemplate(template); } if (context.getService() != null) { agreement.setServiceId(context.getService()); }else{ throw new ModelConversionException("Service is null, field must be informed"); } if (context.getExpirationTime() != null) { agreement.setExpirationDate(context.getExpirationTime()); } List<IServiceProperties> servicePropertiesList = new ArrayList<IServiceProperties>(); List<ServiceProperties> servicePropertiesListXML = agreementXML .getTerms().getAllTerms().getServiceProperties(); if (servicePropertiesListXML == null) { servicePropertiesListXML = Collections .<ServiceProperties> emptyList(); } for (ServiceProperties servicePropertiesXML : servicePropertiesListXML) { IServiceProperties serviceProperties = new eu.atos.sla.datamodel.bean.ServiceProperties(); if (servicePropertiesXML.getName() != null) { serviceProperties.setName(servicePropertiesXML.getName()); } if (servicePropertiesXML.getServiceName() != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML != null) { serviceProperties.setServiceName(servicePropertiesXML.getServiceName()); } if (servicePropertiesXML.getVariableSet() != null) { List<IVariable> variables = new ArrayList<IVariable>(); List<Variable> variablesXML = servicePropertiesXML.getVariableSet().getVariables(); if (variablesXML != null) { for (Variable variableXML : variablesXML) { IVariable variable = new eu.atos.sla.datamodel.bean.Variable(); logger.debug("Variable with name:{} - location:{} - metric:{}", variableXML.getName(), variableXML.getLocation(), variableXML.getMetric()); if (variableXML.getLocation() != null) { variable.setLocation(variableXML.getLocation()); } if (variableXML.getMetric() != null) { variable.setMetric(variableXML.getMetric()); } if (variableXML.getName() != null) { variable.setName(variableXML.getName()); } variables.add(variable); } serviceProperties.setVariableSet(variables); } } servicePropertiesList.add(serviceProperties); } agreement.setServiceProperties(servicePropertiesList); agreement.setName(agreementXML.getName()); List<IGuaranteeTerm> guaranteeTerms = new ArrayList<IGuaranteeTerm>(); List<GuaranteeTerm> guaranteeTermsXML = agreementXML.getTerms() .getAllTerms().getGuaranteeTerms(); if (guaranteeTermsXML == null) { guaranteeTermsXML = Collections.<GuaranteeTerm> emptyList(); } for (GuaranteeTerm guaranteeTermXML : guaranteeTermsXML) { IGuaranteeTerm guaranteeTerm = new eu.atos.sla.datamodel.bean.GuaranteeTerm(); if (guaranteeTermXML.getName() != null) { guaranteeTerm.setName(guaranteeTermXML.getName()); } ServiceScope scope = guaranteeTermXML.getServiceScope(); if (scope != null) { logger.debug("guaranteeTerm with name:{} - servicescopeName:{} - servicescopeValue:{}", guaranteeTermXML.getName(), scope.getServiceName(), scope.getValue()); guaranteeTerm.setServiceScope(scope.getValue()); guaranteeTerm.setServiceName( scope.getServiceName()); }else logger.debug("guaranteeTerm with name:{} - serviceScope is null", guaranteeTermXML.getName() ); if (guaranteeTermXML.getQualifyingCondition()!= null){ logger.debug("qualifying condition informed with:{}", guaranteeTermXML.getQualifyingCondition()); String qc = guaranteeTermXML.getQualifyingCondition(); if (qc != null) { QualifyingConditionParser.Result parsedQc = QualifyingConditionParser.parse(qc); guaranteeTerm.setSamplingPeriodFactor(parsedQc.getSamplingPeriodFactor()); if (parsedQc.getSamplingPeriodFactor() == IGuaranteeTerm.ENFORCED_AT_END) { agreement.setHasGTermToBeEvaluatedAtEndOfEnformcement(true); } } } ServiceLevelObjective slo = guaranteeTermXML.getServiceLevelObjetive(); if (slo.getKpitarget() != null) { if (slo.getKpitarget().getKpiName() != null) { guaranteeTerm.setKpiName(slo.getKpitarget().getKpiName()); String csl = slo.getKpitarget().getCustomServiceLevel(); logger.debug("guaranteeTerm with kpiname:{} -- getCustomServiceLevel: ", slo.getKpitarget().getKpiName(), csl); if (csl != null) { logger.debug("CustomServiceLevel not null"); ServiceLevelParser.Result parsedSlo = ServiceLevelParser.parse(csl); guaranteeTerm.setServiceLevel(parsedSlo.getConstraint()); }else{ logger.debug("CustomServiceLevel is null"); } } } guaranteeTerm.setBusinessValueList(businessValueListParser.parse(guaranteeTermXML)); guaranteeTerms.add(guaranteeTerm); } agreement.setGuaranteeTerms(guaranteeTerms); agreement.setText(payload); return agreement; }  @Override IAgreement getAgreementFromAgreementXML(
            eu.atos.sla.parser.data.wsag.Agreement agreementXML,
            String payload); @Override ITemplate getTemplateFromTemplateXML(eu.atos.sla.parser.data.wsag.Template templateXML,    String payload); @Override Context getContextFromAgreement(IAgreement agreement); @Override IEnforcementJob getEnforcementJobFromEnforcementJobXML(
            EnforcementJob enforcementJobXML); @Override IProvider getProviderFromProviderXML(eu.atos.sla.parser.data.Provider providerXML); @Override Provider getProviderXML(IProvider provider); @Override Violation getViolationXML(IViolation violation); @Override EnforcementJob getEnforcementJobXML(
            IEnforcementJob enforcementJob); @Override Penalty getPenaltyXML(IPenalty penalty); void setBusinessValueListParser(
            BusinessValueListParser customBusinessValueParser);  }