use of io.atlasmap.v2.CollectionType in project atlasmap by atlasmap.
the class SchemaInspector method printParticle.
private void printParticle(XSParticle particle, String rootName, XmlComplexType xmlComplexType) throws Exception {
XSTerm term = particle.getTerm();
if (term.isModelGroup()) {
XSModelGroup group = term.asModelGroup();
printGroup(group, rootName, xmlComplexType);
} else if (term.isModelGroupDecl()) {
printGroupDecl(term.asModelGroupDecl(), rootName, xmlComplexType);
} else if (term.isElementDecl()) {
CollectionType collectionType = getCollectionType(particle);
printElement(term.asElementDecl(), rootName, xmlComplexType, collectionType);
}
}
use of io.atlasmap.v2.CollectionType in project atlasmap by atlasmap.
the class XmlSchemaInspector method printParticle.
private void printParticle(XSParticle particle, XmlComplexType parentXmlComplexType, Set<String> cachedComplexType) throws Exception {
XSTerm term = particle.getTerm();
if (term.isModelGroup()) {
XSModelGroup group = term.asModelGroup();
printGroup(group, parentXmlComplexType, cachedComplexType);
} else if (term.isModelGroupDecl()) {
printGroupDecl(term.asModelGroupDecl(), parentXmlComplexType, cachedComplexType);
} else if (term.isElementDecl()) {
CollectionType collectionType = getCollectionType(particle);
printElement(term.asElementDecl(), parentXmlComplexType, collectionType, cachedComplexType);
}
}
use of io.atlasmap.v2.CollectionType in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method createWmlGetObservationResponse.
/**
* Encodes a SOS GetObservationResponse to a single WaterML 2.0 observation
* or to a WaterML 1.0 ObservationCollection
*
* @param getObservationResonse
* SOS GetObservationResponse
* @return Encoded response
* @throws EncodingException
* If an error occurs
*/
protected XmlObject createWmlGetObservationResponse(GetObservationResponse getObservationResonse) throws EncodingException {
// TODO: set schemaLocation if final
Map<CodeWithAuthority, String> gmlID4sfIdentifier = Maps.newHashMap();
int sfIdCounter = 1;
try {
if (getObservationResonse.getObservationCollection() != null && !getObservationResonse.getObservationCollection().hasNext()) {
ObservationStream observations = getObservationResonse.getObservationCollection();
OmObservation observation = observations.next();
if (!observations.hasNext()) {
OMObservationDocument omObservationDoc = OMObservationDocument.Factory.newInstance(getXmlOptions());
omObservationDoc.setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
return omObservationDoc;
} else {
CollectionDocument xmlCollectionDoc = CollectionDocument.Factory.newInstance(getXmlOptions());
CollectionType wmlCollection = xmlCollectionDoc.addNewCollection();
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
while (observations.hasNext()) {
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observations.next(), gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
}
return xmlCollectionDoc;
}
} else {
// TODO: HydrologieProfile-Exception
throw new EncodingException("Combination does not exists!");
}
} catch (NoSuchElementException | OwsExceptionReport e) {
throw new EncodingException(e);
}
}
use of io.atlasmap.v2.CollectionType in project atlasmap by atlasmap.
the class GenerateInspectionsMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (getOutputDir() != null) {
getOutputDir().mkdirs();
}
CollectionType collectionType = CollectionType.NONE;
if (this.collectionType != null) {
collectionType = CollectionType.valueOf(this.collectionType);
}
if (this.artifacts != null && this.className != null) {
generateJavaInspection(this.artifacts, Arrays.asList(className), collectionType, collectionClassName);
}
if (inspections != null) {
for (Inspection inspection : inspections) {
ArrayList<String> classNames = new ArrayList<>();
if (inspection.classNames != null) {
classNames.addAll(inspection.classNames);
} else if (inspection.className != null) {
classNames.add(inspection.className);
} else {
generateFileInspection(inspection);
}
collectionType = CollectionType.NONE;
if (inspection.collectionType != null) {
collectionType = CollectionType.valueOf(inspection.collectionType);
}
generateJavaInspection(inspection.artifacts, classNames, collectionType, inspection.collectionClassName);
}
}
}
use of io.atlasmap.v2.CollectionType in project atlasmap by atlasmap.
the class KafkaConnectInspector method populateFields.
private List<KafkaConnectField> populateFields(List<org.apache.kafka.connect.data.Field> kcFields, AtlasPath parentPath) {
List<KafkaConnectField> answer = new ArrayList<>();
for (org.apache.kafka.connect.data.Field connectField : kcFields) {
KafkaConnectField field;
AtlasPath path = parentPath.clone();
CollectionType collectionType = CollectionType.NONE;
Schema connectSchema = connectField.schema();
if (Type.ARRAY == connectSchema.type()) {
path.appendField(connectField.name() + AtlasPath.PATH_LIST_SUFFIX);
collectionType = CollectionType.LIST;
connectSchema = connectSchema.valueSchema();
} else if (Type.MAP == connectSchema.type()) {
path.appendField(connectField.name() + AtlasPath.PATH_MAP_SUFFIX);
collectionType = CollectionType.MAP;
connectSchema = connectSchema.valueSchema();
} else {
path.appendField(connectField.name());
}
if (connectSchema.parameters() != null) {
KafkaConnectComplexType complex = AtlasKafkaConnectModelFactory.createKafkaConnectComplexType();
complex.setKafkaConnectEnumFields(new KafkaConnectEnumFields());
complex.setEnumeration(true);
List<KafkaConnectEnumField> symbols = complex.getKafkaConnectEnumFields().getKafkaConnectEnumField();
boolean first = true;
for (Entry<String, String> entry : connectSchema.parameters().entrySet()) {
// FIXME dirty hack - it seems the first entry is for some control, the others are the actual values
if (first) {
first = false;
continue;
}
KafkaConnectEnumField f = new KafkaConnectEnumField();
f.setName(entry.getValue());
symbols.add(f);
}
field = complex;
} else if (connectSchema.type().isPrimitive()) {
field = AtlasKafkaConnectModelFactory.createKafkaConnectField();
field.setFieldType(KafkaConnectUtil.getFieldType(connectSchema.type()));
} else {
KafkaConnectComplexType complex = AtlasKafkaConnectModelFactory.createKafkaConnectComplexType();
List<KafkaConnectField> children = populateFields(connectSchema.fields(), path);
if ("io.confluent.connect.avro.Union".equals(connectSchema.name())) {
// We don't support union until it's built into Kafka Connect Schema
complex.setStatus(FieldStatus.UNSUPPORTED);
}
complex.getKafkaConnectFields().getKafkaConnectField().addAll(children);
field = complex;
}
field.setName(connectField.name());
field.setPath(path.toString());
field.setCollectionType(collectionType);
answer.add(field);
}
return answer;
}
Aggregations