use of org.geotoolkit.wps.xml.v200.DataInput in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImpl method readTaskVariables.
protected void readTaskVariables(UserTask userTask, ProcessTaskFormsGenerationResult result) {
TaskFormVariables formVariables = new TaskFormVariables(userTask);
List<DataInputAssociation> dataInputAssociations = userTask.getDataInputAssociations();
if (dataInputAssociations != null) {
for (DataInputAssociation inputAssociation : dataInputAssociations) {
if (inputAssociation.getTargetRef() != null && !isMIInputCollection(userTask, inputAssociation)) {
String name = ((DataInput) inputAssociation.getTargetRef()).getName();
if (BPMNVariableUtils.isValidInputName(name)) {
String type = extractInputType(inputAssociation);
type = BPMNVariableUtils.getRealTypeForInput(type);
Variable variable = new Variable(name, type);
variable.setInput(true);
formVariables.addVariable(variable);
} else if (BPMNVariableUtils.TASK_FORM_VARIABLE.equals(name)) {
List<Assignment> assignments = inputAssociation.getAssignment();
for (Iterator<Assignment> it = assignments.iterator(); it.hasNext() && StringUtils.isEmpty(formVariables.getTaskName()); ) {
Assignment assignment = it.next();
if (assignment.getFrom() != null) {
String taskName = ((FormalExpression) assignment.getFrom()).getBody();
if (!StringUtils.isEmpty(taskName)) {
// Parsing taskName... it comes in a <![CDATA[]]>
taskName = Parser.xmlParser().parseInput(taskName, "").text();
formVariables.setTaskName(taskName);
}
}
}
}
}
}
}
List<DataOutputAssociation> dataOutputAssociations = userTask.getDataOutputAssociations();
if (dataOutputAssociations != null) {
dataOutputAssociations.forEach(outputAssociation -> {
if (outputAssociation.getSourceRef() != null && outputAssociation.getSourceRef().size() == 1 && !isMIOutputCollection(userTask, outputAssociation)) {
DataOutput output = (DataOutput) outputAssociation.getSourceRef().get(0);
String name = output.getName();
String type = extractOutputType(output);
type = BPMNVariableUtils.getRealTypeForInput(type);
Variable variable = new Variable(name, type);
variable.setOutput(true);
formVariables.addVariable(variable);
}
});
}
if (!StringUtils.isEmpty(formVariables.getTaskName())) {
result.registerTaskFormVariables(userTask.getId(), formVariables);
} else {
logger.warn("Cannot generate a form for task '{}' since it has no form name.", userTask.getName());
}
}
use of org.geotoolkit.wps.xml.v200.DataInput in project geotoolkit by Geomatys.
the class WKTAdaptorTest method adapt.
private static String adapt(final Geometry geom) {
final DataInput value = ADAPTOR.toWPS2Input(geom);
assertNotNull(value);
final List<Object> content = value.getData().getContent();
assertNotNull(content);
assertEquals("Number of values", 1, content.size());
final Object innerContent = content.get(0);
assertTrue(innerContent instanceof ComplexData);
final ComplexData cData = (ComplexData) innerContent;
return (String) cData.getContent().stream().filter(v -> v instanceof String).findAny().orElseThrow(() -> new AssertionError("No String content found"));
}
use of org.geotoolkit.wps.xml.v200.DataInput in project geotoolkit by Geomatys.
the class GMLAdaptor method toWPS2Input.
@Override
public DataInput toWPS2Input(Object candidate) throws UnconvertibleObjectException {
if (candidate instanceof ReferenceProxy)
return super.toWPS2Input(candidate);
final ComplexData cdt = new ComplexData();
cdt.getContent().add(new org.geotoolkit.wps.xml.v200.Format(encoding, mimeType, schema, null));
final JAXPStreamFeatureWriter writer = new JAXPStreamFeatureWriter(gmlVersion, null, null);
try {
if (ENC_BASE64.equalsIgnoreCase(encoding)) {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
writer.write(candidate, out);
out.flush();
String base64 = Base64.getEncoder().encodeToString(out.toByteArray());
cdt.getContent().add(base64);
} else if (ENC_UTF8.equalsIgnoreCase(encoding)) {
final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
final DocumentBuilder constructeur = fabrique.newDocumentBuilder();
final Document document = constructeur.newDocument();
final DOMResult domResult = new DOMResult(document);
writer.write(candidate, domResult);
cdt.getContent().add(document.getDocumentElement());
}
} catch (IOException | XMLStreamException | DataStoreException | ParserConfigurationException ex) {
throw new UnconvertibleObjectException(ex.getMessage(), ex);
}
final Data data = new Data();
data.getContent().add(cdt);
final DataInput dit = new DataInput();
dit.setData(data);
return dit;
}
use of org.geotoolkit.wps.xml.v200.DataInput in project geotoolkit by Geomatys.
the class OctetStreamAdaptor method toWPS2Input.
@Override
public DataInput toWPS2Input(Path candidate) throws UnconvertibleObjectException {
if (candidate instanceof ReferenceProxy)
return super.toWPS2Input(candidate);
final byte[] bytes;
try {
bytes = Files.readAllBytes(candidate);
} catch (IOException ex) {
throw new UnconvertibleObjectException(ex.getMessage(), ex);
}
final String base64 = Base64.getEncoder().encodeToString(bytes);
final DataInput dit = new DataInput();
final Data data = new Data();
data.setEncoding("base64");
data.getContent().add(base64);
dit.setData(data);
return dit;
}
use of org.geotoolkit.wps.xml.v200.DataInput in project geotoolkit by Geomatys.
the class WKTAdaptor method toWPS2Input.
@Override
public DataInput toWPS2Input(Object candidate) throws UnconvertibleObjectException {
if (candidate instanceof ReferenceProxy)
return super.toWPS2Input(candidate);
final ComplexData cdt = new ComplexData();
cdt.getContent().add(new org.geotoolkit.wps.xml.v200.Format(encoding, mimeType, null, null));
Geometry geom = (Geometry) candidate;
int srid = 0;
int dimension = 2;
try {
CoordinateReferenceSystem crs = Geometries.wrap(geom).get().getCoordinateReferenceSystem();
if (crs != null) {
dimension = crs.getCoordinateSystem().getDimension();
final IdentifiedObjectFinder finder = IdentifiedObjects.newFinder("EPSG");
// TODO: Ensure no project strongly rely on that, then remove. It's pure non-sense/madness.
// Note: If you read this after march 2020: do not ask : delete.
finder.setIgnoringAxes(true);
final CoordinateReferenceSystem epsgcrs = (CoordinateReferenceSystem) finder.findSingleton(crs);
if (epsgcrs != null) {
srid = IdentifiedObjects.lookupEPSG(epsgcrs);
// force geometry in longitude first
final CoordinateReferenceSystem crs2 = ((AbstractCRS) crs).forConvention(AxesConvention.RIGHT_HANDED);
if (crs2 != crs) {
geom = org.apache.sis.internal.feature.jts.JTS.transform(geom, crs2);
}
if (crs2 != null)
dimension = crs2.getCoordinateSystem().getDimension();
}
}
} catch (FactoryException | MismatchedDimensionException | TransformException ex) {
throw new UnconvertibleObjectException(ex.getMessage(), ex);
}
// String wkt = geom.toText();
WKTWriter writer = new WKTWriter(dimension);
String wkt = writer.write(geom);
if (srid > 0) {
wkt = "SRID=" + srid + ";" + wkt;
}
cdt.getContent().add(wkt);
final Data data = new Data();
data.getContent().add(cdt);
final DataInput dit = new DataInput();
dit.setData(data);
return dit;
}
Aggregations