<commit_before>package se.skltp.aggregatingservices.riv.clinicalprocess.activity.actions.getaggregatedactivity;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.soitoolkit.commons.mule.jaxb.JaxbUtil;
import org.w3c.dom.Node;

import riv.clinicalprocess.activity.actions.getactivityresponder.v1.GetActivityType;
import se.skltp.agp.riv.itintegration.engagementindex.findcontentresponder.v1.FindContentType;
import se.skltp.agp.service.api.QueryObject;
import se.skltp.agp.service.api.QueryObjectFactory;

public class QueryObjectFactoryImpl implements QueryObjectFactory {

	private static final Logger log = LoggerFactory.getLogger(QueryObjectFactoryImpl.class);
	private static final JaxbUtil ju = new JaxbUtil(GetActivityType.class);

	private String eiServiceDomain;
	public void setEiServiceDomain(String eiServiceDomain) {
		this.eiServiceDomain = eiServiceDomain;
	}

	private String eiCategorization;
	public void setEiCategorization(String eiCategorization) {
		this.eiCategorization = eiCategorization;
	}

	/**
	 * Transformerar GetActivity request till EI FindContent request enligt:
	 * 
	 * 1. subjectOfCareId --> registeredResidentIdentification
	 * 2. "riv:clinicalprocess:activity:actions" --> serviceDomain
	 * 3. "caa-ga" --> categorization
	 */
	public QueryObject createQueryObject(Node node) {
		final GetActivityType request = (GetActivityType)ju.unmarshal(node);
		if(log.isDebugEnabled() && request.getPatientId() != null) {
			log.debug("Transformed payload for pid: {}", request.getPatientId().getExtension());
		}
		final FindContentType fc = new FindContentType();
		
		if(request.getPatientId() != null) {
			fc.setRegisteredResidentIdentification(request.getPatientId().getExtension());
		}
		fc.setServiceDomain(eiServiceDomain);
		fc.setCategorization(eiCategorization);
		
		return new QueryObject(fc, request);	
	}
	
	protected String getSourceSystem(final GetActivityType request) {
		if(request.getSourceSystemId() == null || StringUtils.isBlank(request.getSourceSystemId().getExtension())) {
			return null;
		}
		return request.getSourceSystemId().getExtension();
	}
}
<commit_msg>Refactored<commit_after>package se.skltp.aggregatingservices.riv.clinicalprocess.activity.actions.getaggregatedactivity;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.soitoolkit.commons.mule.jaxb.JaxbUtil;
import org.w3c.dom.Node;

import riv.clinicalprocess.activity.actions.getactivityresponder.v1.GetActivityType;
import se.skltp.agp.riv.itintegration.engagementindex.findcontentresponder.v1.FindContentType;
import se.skltp.agp.service.api.QueryObject;
import se.skltp.agp.service.api.QueryObjectFactory;

public class QueryObjectFactoryImpl implements QueryObjectFactory {

	private static final Logger log = LoggerFactory.getLogger(QueryObjectFactoryImpl.class);
	private static final JaxbUtil ju = new JaxbUtil(GetActivityType.class);

	private String eiServiceDomain;
	public void setEiServiceDomain(String eiServiceDomain) {
		this.eiServiceDomain = eiServiceDomain;
	}

	private String eiCategorization;
	public void setEiCategorization(String eiCategorization) {
		this.eiCategorization = eiCategorization;
	}

	/**
	 * Transformerar GetActivity request till EI FindContent request enligt:
	 * 
	 * 1. subjectOfCareId --> registeredResidentIdentification
	 * 2. "riv:clinicalprocess:activity:actions" --> serviceDomain
	 * 3. "caa-ga" --> categorization
	 */
	public QueryObject createQueryObject(Node node) {
		final GetActivityType request = (GetActivityType)ju.unmarshal(node);
		if(log.isDebugEnabled() && request.getPatientId() != null) {
			log.debug("Transformed payload for pid: {}", request.getPatientId().getExtension());
		}
		final FindContentType fc = new FindContentType();
		
		if(request.getPatientId() != null) {
			fc.setRegisteredResidentIdentification(request.getPatientId().getExtension());
		}
		fc.setServiceDomain(eiServiceDomain);
		fc.setCategorization(eiCategorization);
		
		return new QueryObject(fc, request);	
	}
}

{'fraction_non_alphanumeric': 0.10323837350864377, 'fraction_numerical': 0.0038957876795714633, 'mean_word_length': 5.9391891891891895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5666321', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1253, 'n_words': 218}