public RecordFilterAppender assemble(ConfigurationContext context) {

    if (restrictions.length == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ELEMENT_REQUIRED,
                  context.getElement().getTagName(),
                  "sx:regexCriteria, sx:restriction");
      throw new ServingXmlException(message);
    }

    BooleanOperatorEnum operatorEnum;
    try {
      operatorEnum = BooleanOperatorEnum.parse(operator);
    } catch (ServingXmlException e) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_VALUE_INVALID,
                  context.getElement().getTagName(),
                  "operator");
      e = e.supplementMessage(message);
      throw e;
    }

    RecordFilterAppender recordFilterAppender =
        new RestrictRecordFilterAppender(restrictions, operatorEnum, unmatchedRecord);
    if (parameterDescriptors.length > 0) {
      recordFilterAppender =
          new RecordFilterAppenderPrefilter(recordFilterAppender, parameterDescriptors);
    }
    return recordFilterAppender;
  }
  public FlatRecordFieldFactory assemble(ConfigurationContext context) {

    if (fieldName.isEmpty()) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "name");
      throw new ServingXmlException(message);
    }

    if (digitCount <= 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "digitCount");
      throw new ServingXmlException(message);
    }

    if (width <= 0) {
      width = PackedDecimal.calculatePackedSize(digitCount);
    }

    FlatFileOptionsFactory flatFileOptionsFactory = assembleFlatFileOptions(context);

    if (label == null) {
      if (fieldLabel != null) {
        SubstitutionExpr subExpr =
            SubstitutionExpr.parseString(context.getQnameContext(), fieldLabel);
        ValueEvaluator valueEvaluator = new SubstitutionExprValueEvaluator(subExpr);
        label = new Label(valueEvaluator);
      } else {
        label = new Label(fieldName.getLocalName());
      }
    }

    FlatRecordFieldFactory fieldTypeFactory =
        new PackedDecimalFieldFactory(
            fieldName,
            label,
            start,
            width,
            digitCount,
            decimalPlaces,
            defaultValue,
            flatFileOptionsFactory);

    return fieldTypeFactory;
  }
Ejemplo n.º 3
0
  public Content assemble(ConfigurationContext context) {

    if (xsltConfiguration == null) {
      xsltConfiguration = XsltConfiguration.getDefault();
    }

    if (queryFactory == null && stringQueryFactory == null) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ELEMENT_REQUIRED,
                  context.getElement().getTagName(),
                  "sx:stringable or sx:streamSource");
      throw new ServingXmlException(message);
    }

    if (queryFactory == null) {
      ValueEvaluator valueEvaluator = new StringValueEvaluator(stringQueryFactory);
      queryFactory = new StringStreamSourceFactory(valueEvaluator);
    }
    if (contextDocument == null) {
      contextDocument = new DefaultDocument(xsltConfiguration.getOutputPropertyFactories());
    }
    if (baseUri == null) {
      baseUri = context.getQnameContext().getBase();
    }

    PrefixMap prefixMap = DomHelper.createPrefixMap(context.getElement());

    Content contentFactory =
        new XQueryContent(
            baseUri,
            prefixMap,
            queryFactory,
            contextDocument,
            xsltConfiguration.getOutputPropertyFactories());
    if (parameterDescriptors.length > 0) {
      contentFactory = new ContentPrefilter(contentFactory, parameterDescriptors);
    }
    return contentFactory;
  }
Ejemplo n.º 4
0
  public FtpClient assemble(ConfigurationContext context) {

    if (host == null || host.length() == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "host");
      throw new ServingXmlException(message);
    }

    if (user == null || user.length() == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "user");
      throw new ServingXmlException(message);
    }

    try {
      return new FtpClient(host, port, user, password, remoteSiteCommand);
    } catch (ServingXmlException e) {
      throw e.contextualizeMessage(context.getElement().getTagName());
    } catch (Exception e) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ERROR,
                  context.getElement().getTagName(),
                  e.getMessage());
      throw new ServingXmlException(message, e);
    }
  }
  public MapXmlFactory assemble(ConfigurationContext context) {

    if (elementQname == null || elementQname.length() == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "element");
      throw new ServingXmlException(message);
    }

    try {
      if (xsltConfiguration == null) {
        xsltConfiguration = XsltConfiguration.getDefault();
      }

      NameSubstitutionExpr nameResolver =
          NameSubstitutionExpr.parse(context.getQnameContext(), elementQname);

      StringFactory stringFactory =
          StringFactoryCompiler.fromStringables(context, context.getElement());
      StringFactory[] stringFactories = new StringFactory[] {stringFactory};

      MapXmlFactory rmf =
          new MultipleMapXmlFactory(context.getQnameContext(), xsltConfiguration, childFactories);

      if (sorts.length > 0) {
        Comparator comparator = new SortComparator(sorts);
        rmf = new SortGroupFactory(rmf, comparator);
      }
      Environment env = new Environment(parameterDescriptors, context.getQnameContext());
      MapXmlFactory recordMapFactory =
          new ElementMapFactory(env, nameResolver, stringFactories, rmf);
      return recordMapFactory;
    } catch (ServingXmlException e) {
      throw e.contextualizeMessage(context.getElement().getTagName());
    } catch (Exception e) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ERROR,
                  context.getElement().getTagName(),
                  e.getMessage());
      throw new ServingXmlException(message, e);
    }
  }
  public RecordCombinationFactory assemble(ConfigurationContext context) {
    Environment env = new Environment(parameterDescriptors, context.getQnameContext());

    if (recordTypeName.length() == 0) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "recordType");
      throw new ServingXmlException(message);
    }

    NameSubstitutionExpr recordTypeNameExpr =
        NameSubstitutionExpr.parse(context.getQnameContext(), recordTypeName);

    if (dataRecordTypeFactory == null) {
      String message =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ELEMENT_REQUIRED,
                  context.getElement().getTagName(),
                  "sx:flatRecordType");
      throw new ServingXmlException(message);
    }

    if (repeatingGroupFieldName.isEmpty()) {
      String msg =
          MessageFormatter.getInstance()
              .getMessage(
                  ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED,
                  context.getElement().getTagName(),
                  "repeatingGroup");
      throw new ServingXmlException(msg);
    }

    String baseUri = context.getQnameContext().getBase();
    XPathBooleanExpressionFactory startTestFactory;
    if (startTest.length() > 0) {
      startTestFactory =
          new XPathBooleanExpressionFactoryImpl(
              context.getQnameContext(),
              startTest,
              xsltConfiguration.getVersion(),
              baseUri,
              xsltConfiguration.getTransformerFactory());
    } else {
      startTestFactory =
          new SimpleXPathBooleanExpressionFactory(XPathBooleanExpression.ALWAYS_TRUE);
    }
    XPathBooleanExpressionFactory endTestFactory;
    if (endTest.length() > 0) {
      endTestFactory =
          new XPathBooleanExpressionFactoryImpl(
              context.getQnameContext(),
              endTest,
              xsltConfiguration.getVersion(),
              baseUri,
              xsltConfiguration.getTransformerFactory());
    } else {
      endTestFactory = startTestFactory;
    }

    GroupRecognizer groupRecognizer =
        new GroupRecognizerImpl(
            env.getQnameContext().getPrefixMap(), startTestFactory, endTestFactory);

    FlatFileOptionsFactory flatFileOptionsFactory = assembleFlatFileOptions(context);

    RecordCombinationFactory recordCompositionFactory =
        new CombineFlatRecordsFactory(
            recordTypeNameExpr,
            repeatingGroupFieldName,
            groupRecognizer,
            dataRecordTypeFactory,
            flatFileOptionsFactory);
    // if (parameterDescriptors.length > 0) {
    //  recordCompositionFactory = new FlatRecordTypeFactoryPrefilter(recordCompositionFactory,
    //                                                         parameterDescriptors);
    // }
    return recordCompositionFactory;
  }