Example #1
0
 @Override
 public List<String> getValidityErrors() {
   List<String> allErrors = new ArrayList<String>();
   for (ModelMetaData model : this.models.values()) {
     List<Message> errors = model.getMessages();
     if (errors != null && !errors.isEmpty()) {
       for (Message m : errors) {
         if (m.getSeverity() == Severity.ERROR) {
           allErrors.add(m.getValue());
         }
       }
     }
   }
   return allErrors;
 }
Example #2
0
  private static void writeModel(final XMLStreamWriter writer, ModelMetaData model)
      throws XMLStreamException {
    writer.writeStartElement(Element.MODEL.getLocalName());
    writeAttribute(writer, Element.NAME.getLocalName(), model.getName());
    writeAttribute(writer, Element.TYPE.getLocalName(), model.getModelType().name());

    writeAttribute(writer, Element.VISIBLE.getLocalName(), String.valueOf(model.isVisible()));
    writeAttribute(writer, Element.PATH.getLocalName(), model.getPath());

    if (model.getDescription() != null) {
      writeElement(writer, Element.DESCRIPTION, model.getDescription());
    }
    writeProperties(writer, model.getProperties());

    // source mappings
    for (SourceMappingMetadata source : model.getSourceMappings()) {
      writer.writeStartElement(Element.SOURCE.getLocalName());
      writeAttribute(writer, Element.NAME.getLocalName(), source.getName());
      writeAttribute(
          writer, Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName(), source.getTranslatorName());
      writeAttribute(
          writer,
          Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName(),
          source.getConnectionJndiName());
      writer.writeEndElement();
    }

    if (model.getSchemaSourceType() != null) {
      writer.writeStartElement(Element.METADATA.getLocalName());
      writeAttribute(writer, Element.TYPE.getLocalName(), model.getSchemaSourceType());
      writer.writeCData(model.getSchemaText());
      writer.writeEndElement();
    }

    // model validation errors
    for (Message ve : model.getMessages(false)) {
      writer.writeStartElement(Element.VALIDATION_ERROR.getLocalName());
      writeAttribute(
          writer, Element.VALIDATION_SEVERITY_ATTR.getLocalName(), ve.getSeverity().name());
      writeAttribute(writer, Element.PATH.getLocalName(), ve.getPath());
      writer.writeCharacters(ve.getValue());
      writer.writeEndElement();
    }
    writer.writeEndElement();
  }