class RuleExecutionUtils {

    public static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource,
            String executionId, Type annotationType, PacmanRule ruleAnnotation) {

        Annotation annotation = Annotation.buildAnnotation(ruleParam, annotationType);
        annotation.put(PacmanSdkConstants.EXECUTION_ID, executionId);
        if (null != ruleAnnotation) {
            annotation.put(PacmanSdkConstants.RULE_CATEGORY, ruleAnnotation.category());
            annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleAnnotation.severity());
        }
        if (null != ruleParam) {
            annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, ruleParam.get(PacmanSdkConstants.DATA_SOURCE_KEY));
            annotation.put(PacmanSdkConstants.TARGET_TYPE, ruleParam.get(PacmanSdkConstants.TARGET_TYPE));
            annotation.put(PacmanSdkConstants.RULE_ID, ruleParam.get(PacmanSdkConstants.RULE_ID));
            if (ruleParam.containsKey(PacmanSdkConstants.INVOCATION_ID)) {
                annotation.put(PacmanSdkConstants.INVOCATION_ID, ruleParam.get(PacmanSdkConstants.INVOCATION_ID));
            }
            if (ruleParam.containsKey(PacmanSdkConstants.RULE_SEVERITY)) {
                annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleParam.get(PacmanSdkConstants.RULE_SEVERITY));
            }
        }
        if (null != resource) {
            annotation.put(PacmanSdkConstants.RESOURCE_ID, resource.get(PacmanSdkConstants.RESOURCE_ID));
            annotation.put(PacmanSdkConstants.ACCOUNT_ID, resource.get(PacmanSdkConstants.ACCOUNT_ID));
            annotation.put(PacmanSdkConstants.REGION, resource.get(PacmanSdkConstants.REGION));
            annotation.put(PacmanSdkConstants.ACCOUNT_NAME, resource.get(PacmanSdkConstants.ACCOUNT_NAME));
            annotation.put(PacmanSdkConstants.DOC_ID, resource.get(PacmanSdkConstants.DOC_ID));
            if (resource.containsKey(PacmanSdkConstants.APPLICATION_TAG_KEY)) {
                annotation.put(PacmanSdkConstants.APPLICATION_TAG_KEY,
                        resource.get(PacmanSdkConstants.APPLICATION_TAG_KEY));
            }
            if (resource.containsKey(PacmanSdkConstants.ENV_TAG_KEY)) {
                annotation.put(PacmanSdkConstants.ENV_TAG_KEY, resource.get(PacmanSdkConstants.ENV_TAG_KEY));
            }
        }

        return annotation;
    }

}