ArrayOfCharacteristic translateCharacteristics(ScorisQig scorisQig) throws TranslatorException {
   ArrayOfCharacteristic arrayOfCharacteristic = new ArrayOfCharacteristic();
   List<com.rm.scoris.schemas._2009._03.markschemestructure.Characteristic> rmCharacteristics =
       arrayOfCharacteristic.getCharacteristic();
   QigAttributes qigAttributes = scorisQig.getQigAttributes();
   throwExceptionForNullInput(qigAttributes, "qigAttributes");
   rmCharacteristics.addAll(createCharacteristics(qigAttributes.getCharacteristics()));
   return arrayOfCharacteristic;
 }
 public boolean deriveEStandardisationIndicator(
     ScorisQig scorisQig, ExaminationPaper examinationPaper) {
   QigAttributes qigAttributes = scorisQig.getQigAttributes();
   return (examinationPaper
           .getQualityModel()
           .getQualityMethod()
           .equalsIgnoreCase(SEEDING_QUALITY_METHOD)
       || qigAttributes.hasTarget(TargetType.Creation, PRACTICE_TARGET_MODE)
       || qigAttributes.hasTarget(TargetType.Creation, STANDARDISATION_TARGET_MODE));
 }
  private QuestionItemGroup createQuestionItemGroup(
      ScorisQig scorisQig, ExaminationPaper examinationPaper) throws TranslatorException {
    Integer maxResponses = null;
    QuestionItemGroup qig = new QuestionItemGroup();
    QigAttributes qigAttributes = scorisQig.getQigAttributes();
    Markscheme markscheme = examinationPaper.getMarkscheme();

    throwExceptionForNullInput(qigAttributes, "qigAttributes");
    throwExceptionForNullInput(qigAttributes.getGracePeriod(), "qigAttributes.getGracePeriod()");

    qig.setQuestionItemGroupIdentifier(scorisQig.getId());
    qig.setName(scorisQig.getName());
    // qig.setDefaultGrace(qigAttributes.getGracePeriod());
    qig.setDefaultGrace(qigAttributes.getGracePeriod() * 60);
    qig.setEStandardisationIndicator(deriveEStandardisationIndicator(scorisQig, examinationPaper));

    throwExceptionForNullInput(
        qigAttributes.getConcurrentLimit(), "qigAttributes.getConcurrentLimit()");
    qig.setMaximumConcurrentMarkingLimit(qigAttributes.getConcurrentLimit());
    qig.setMaximumCacheLimit(getMaximumCacheLimit(qig));
    qig.setMarkingTolerance(
        getMarkingTolerance(examinationPaper.getQualityModel(), scorisQig.getMarkGroup()));
    qig.setTMDTolerance(
        getTmdTolerance(examinationPaper.getQualityModel(), scorisQig.getMarkGroup()));
    maxResponses = markscheme.getTotalCompulsoryQuestions();
    if (maxResponses == null) {
      maxResponses = markscheme.getNumberOfClusters();
    }
    qig.setExpectedMaxResponses(maxResponses);
    qig.setMarkingApplicationIdentifier("SCORIS");
    /* MarkingCount is a legacy field which is a required parameter
     * RM actually ignore it and calculate it themselves - Rebecca Richardson */
    qig.setMarkingCount(1);

    qig.setEStandardisationCreationTargets(translateEStandardisationCreationTargets(scorisQig));
    handleSeedingCreationTarget(
        scorisQig.getQigAttributes(),
        examinationPaper.getQualityModel(),
        qig.getEStandardisationCreationTargets());

    qig.setCharacteristics(translateCharacteristics(scorisQig));

    qig.setExceptionTypes(translateExceptionTypes(markscheme.getExceptions()));
    qig.setAnnotations(translateAnnotations(markscheme.getOrderedAnnotations()));

    /** we don't translate any sample rules as of now! */
    return qig;
  }
  ArrayOfEStandardisationCreationTarget translateEStandardisationCreationTargets(
      ScorisQig scorisQig) throws TranslatorException {
    ArrayOfEStandardisationCreationTarget arrayOfEStandardisationCreationTarget =
        new ArrayOfEStandardisationCreationTarget();
    QigAttributes qigAttributes = scorisQig.getQigAttributes();
    throwExceptionForNullInput(qigAttributes, "qigAttributes");

    List<EStandardisationCreationTarget> eStandardisationCreationTargets =
        arrayOfEStandardisationCreationTarget.getEStandardisationCreationTarget();
    for (Target target : qigAttributes.getTargets(TargetType.Creation)) {
      EStandardisationCreationTarget eStdCreationTarget = new EStandardisationCreationTarget();
      eStdCreationTarget.setMarkingModeName(target.getTargetMode().getModeType());
      throwExceptionForNullInput(target.getTargetQuantity(), "target.targetQuantity");
      eStdCreationTarget.setTarget(target.getTargetQuantity());
      eStandardisationCreationTargets.add(eStdCreationTarget);
    }
    return arrayOfEStandardisationCreationTarget;
  }
 private void handleSeedingCreationTarget(
     QigAttributes qigAttributes,
     QualityModel qualityModel,
     ArrayOfEStandardisationCreationTarget creationTargets)
     throws TranslatorException {
   if (qualityModel.getQualityMethod().equalsIgnoreCase(SEEDING_QUALITY_METHOD)) {
     Float seedingPercentage = qigAttributes.getSeedingCreationPercentage();
     if (seedingPercentage == null) {
       throw new TranslatorException(
           "A seeding creation percentage is required for a paper configured with a seeding quality method");
     }
     EStandardisationCreationTarget seedingCreationTarget = new EStandardisationCreationTarget();
     seedingCreationTarget.setMarkingModeName("Seeding");
     Integer liveMarkingTarget =
         getLiveMarkingTarget(qigAttributes.getTargets(TargetType.Marking));
     seedingCreationTarget.setTarget(
         (int) Math.ceil((seedingPercentage / 100) * liveMarkingTarget));
     creationTargets.getEStandardisationCreationTarget().add(seedingCreationTarget);
   }
 }