<commit_before>/*
 * Copyright 2012-2013 inBloom, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.slc.sli.bulk.extract.treatment;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slc.sli.domain.Entity;

/** Embed subdocs into Assessment and StudentAssessment entities.
 * 
 * @author tshewchuk
 *
 */
public class AssessmentTreatment implements Treatment{

    @Override
    public Entity apply(Entity entity) {
        // Assessment and StudentAssessment entities are special cases.
        if (entity.getType().equals("assessment") || entity.getType().equals("studentAssessment")) {
            Map<String, List<Entity>> subdocs = entity.getEmbeddedData();
            for (Map.Entry<String, List<Entity>> subdoc : subdocs.entrySet()) {
                List<Map<String, Object>> subdocList = new ArrayList<Map<String, Object>>();
                for (Entity subdocItem : subdoc.getValue()) {
                    if (subdocItem.getType().equals("objectiveAssessment")) {
                        subdocItem.getBody().remove("assessmentItemReference");
                        subdocItem.getBody().remove("assessmentId");
                    } else if (subdocItem.getType().equals("assessmentItem")) {
                        subdocItem.getBody().remove("assessmentId");
                    }
                    subdocList.add(subdocItem.getBody());
                }
                entity.getBody().put(subdoc.getKey(), subdocList);
            }
        }

        return entity;
    }

}<commit_msg>US5527: Added Assessment treatment<commit_after>/*
 * Copyright 2012-2013 inBloom, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.slc.sli.bulk.extract.treatment;

import org.springframework.beans.factory.annotation.Autowired;

import org.slc.sli.dal.convert.SuperdocConverter;
import org.slc.sli.domain.Entity;

/** Embed subdocs into Assessment and StudentAssessment entities.
 *
 * @author tshewchuk
 *
 */
public class AssessmentTreatment implements Treatment{

    @Autowired
    private SuperdocConverter assessmentConverter;

    @Override
    public Entity apply(Entity entity) {
        if (entity.getType().equals("assessment")){
            assessmentConverter.subdocToBodyField(entity);
        }

        return entity;
    }

    /**
     * Get assessment converter.
     * @return the assessmentConverter
     */
    public SuperdocConverter getAssessmentConverter() {
        return assessmentConverter;
    }

    /**
     * Set assessment converter.
     * @param assessmentConverter the assessmentConverter to set
     */
    public void setAssessmentConverter(SuperdocConverter assessmentConverter) {
        this.assessmentConverter = assessmentConverter;
    }

}
{'fraction_non_alphanumeric': 0.09531290913851793, 'fraction_numerical': 0.007331762241424456, 'mean_word_length': 2.9585492227979273, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3407764', 'n_tokens_mistral': 1015, 'n_tokens_neox': 967, 'n_words': 308}