use of org.geotoolkit.sml.xml.v101.ComponentType in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createSensorMLDescription.
protected SensorMLDocument createSensorMLDescription(final SensorML smlSensorDesc) throws EncodingException {
final SensorMLDocument sensorMLDoc = SensorMLDocument.Factory.newInstance(getXmlOptions());
final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSensorML = sensorMLDoc.addNewSensorML();
xbSensorML.setVersion(SensorMLConstants.VERSION_V101);
if (smlSensorDesc.isSetMembers()) {
for (final AbstractProcess sml : smlSensorDesc.getMembers()) {
if (sml instanceof System) {
final SystemType xbSystem = (SystemType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_SYSTEM), SystemType.type);
final System smlSystem = (System) sml;
addAbstractProcessValues(xbSystem, smlSystem);
addSystemValues(xbSystem, smlSystem);
} else if (sml instanceof ProcessModel) {
final ProcessModelType xbProcessModel = (ProcessModelType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_PROCESS_MODEL), ProcessModelType.type);
final ProcessModel smlProcessModel = (ProcessModel) sml;
addAbstractProcessValues(xbProcessModel, smlProcessModel);
addProcessModelValues(xbProcessModel, smlProcessModel);
} else if (sml instanceof org.n52.shetland.ogc.sensorML.Component) {
final ComponentType xbCompontent = (ComponentType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_COMPONENT), ComponentType.type);
final org.n52.shetland.ogc.sensorML.Component smlComponent = (org.n52.shetland.ogc.sensorML.Component) sml;
addAbstractProcessValues(xbCompontent, smlComponent);
addComponentValues(xbCompontent, smlComponent);
}
}
}
return sensorMLDoc;
}
use of org.geotoolkit.sml.xml.v101.ComponentType in project AMASE by loonwerks.
the class GenMCSHandler method runJob.
@Override
protected IStatus runJob(Element root, IProgressMonitor monitor) {
EphemeralImplementationUtil implUtil = new EphemeralImplementationUtil(monitor);
// this flag is set by the rerun handler to prevent clearing the advice map
if (!calledFromRerun) {
rerunAdviceMap.clear();
}
calledFromRerun = false;
disableRerunHandler();
handlerService = getWindow().getService(IHandlerService.class);
try {
// Make sure the user selected a component implementation
ComponentImplementation ci = getComponentImplementation(root, implUtil);
SystemInstance si = getSysInstance(ci, implUtil);
AnalysisResult result;
CompositeAnalysisResult wrapper = new CompositeAnalysisResult("");
// SystemType sysType = si.getSystemImplementation().getType();
ComponentType sysType = AgreeUtils.getInstanceType(si);
EList<AnnexSubclause> annexSubClauses = AnnexUtil.getAllAnnexSubclauses(sysType, AgreePackage.eINSTANCE.getAgreeContractSubclause());
if (annexSubClauses.size() == 0) {
throw new AgreeException("There is not an AGREE annex in the '" + sysType.getName() + "' system type.");
}
if (isRecursive()) {
if (AgreeUtils.usingKind2()) {
throw new AgreeException("Kind2 only supports monolithic verification");
}
result = buildAnalysisResult(((NamedElement) root).getName(), si);
wrapper.addChild(result);
result = wrapper;
} else if (isRealizability()) {
AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, false);
Program program = LustreAstBuilder.getRealizabilityLustreProgram(agreeProgram);
wrapper.addChild(createVerification("Realizability Check", si, program, agreeProgram, AnalysisType.Realizability));
result = wrapper;
} else {
wrapVerificationResult(si, wrapper);
result = wrapper;
}
showView(result, linker);
return doAnalysis(root, monitor, result, linker);
} catch (Throwable e) {
String messages = getNestedMessages(e);
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
} finally {
implUtil.cleanup();
}
}
use of org.geotoolkit.sml.xml.v101.ComponentType in project osate2 by osate.
the class CreateFeaturePaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
return ctx.getTarget().getBusinessObject(EObject.class).map(targetBo -> {
final AadlOperationBuilder<Classifier> opBuilder = AadlOperationBuilder.classifiers().filter(c -> AadlFeatureUtil.canOwnFeatureType(c, featureType));
if (!opBuilder.canBuildOperation(targetBo)) {
return null;
}
return Operation.createWithBuilder(createOp -> {
// Create the feature
opBuilder.buildOperation(createOp, targetBo).modifyPreviousResult(owner -> {
final String newFeatureName = AadlNamingUtil.buildUniqueIdentifier(owner, "new_feature");
final NamedElement newFeature = AadlFeatureUtil.createFeature(owner, featureType);
newFeature.setName(newFeatureName);
// Set in or out based on target docking position
final boolean isRight = ctx.getDockingPosition() == DockingPosition.RIGHT;
if (newFeature instanceof DirectedFeature) {
if (!(newFeature instanceof FeatureGroup)) {
final DirectedFeature newDirectedFeature = (DirectedFeature) newFeature;
newDirectedFeature.setIn(!isRight);
newDirectedFeature.setOut(isRight);
}
} else if (newFeature instanceof Access) {
final Access access = (Access) newFeature;
access.setKind(isRight ? AccessType.PROVIDES : AccessType.REQUIRES);
}
if (owner instanceof ComponentType) {
((ComponentType) owner).setNoFeatures(false);
}
return StepResultBuilder.create().showNewBusinessObject(ctx.getTarget(), newFeature).build();
});
});
});
}
use of org.geotoolkit.sml.xml.v101.ComponentType in project osate2 by osate.
the class CreateFlowSourceSinkSpecificationPaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
return ctx.getTarget().getBusinessObject(Feature.class).map(feature -> {
final DirectionType requiredDirection;
if (flowKind == FlowKind.SOURCE) {
requiredDirection = DirectionType.OUT;
} else if (flowKind == FlowKind.SINK) {
requiredDirection = DirectionType.IN;
} else {
return null;
}
final List<ComponentType> potentialOwners = FlowSpecificationCreationUtil.getPotentialOwnersByFeature(ctx.getTarget(), ctx.getQueryService());
if (potentialOwners.isEmpty() || !FlowSpecificationCreationUtil.isValidFlowEnd(feature, ctx.getTarget(), requiredDirection, ctx.getQueryService())) {
return null;
}
final BusinessObjectContext container = FlowSpecificationCreationUtil.getFlowSpecificationOwnerBoc(ctx.getTarget(), ctx.getQueryService());
if (container == null) {
return null;
}
return Operation.createWithBuilder(createOp -> {
AadlUiUtil.selectClassifier(createOp, potentialOwners).modifyPreviousResult(ct -> {
final FlowSpecification fs = ct.createOwnedFlowSpecification();
fs.setKind(flowKind);
fs.setName(FlowSpecificationCreationUtil.getNewFlowSpecificationName(ct));
// Create the appropriate flow end depending on the type being created
final FlowEnd flowEnd;
if (flowKind == FlowKind.SOURCE) {
flowEnd = fs.createOutEnd();
} else if (flowKind == FlowKind.SINK) {
flowEnd = fs.createInEnd();
} else {
throw new RuntimeException("Unexpected flow kind: " + flowKind);
}
flowEnd.setFeature(feature);
flowEnd.setContext(FlowSpecificationCreationUtil.getContext(ctx.getTarget(), ctx.getQueryService()));
// Clear the no flows flag
ct.setNoFlows(false);
return StepResultBuilder.create().showNewBusinessObject(container, fs).build();
});
});
});
}
use of org.geotoolkit.sml.xml.v101.ComponentType in project osate2 by osate.
the class CreateGeneralizationPaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetCreateConnectionOperationContext ctx) {
final Object readonlySubtype = ctx.getSource().getBusinessObject();
final Classifier supertype = ctx.getDestination().getBusinessObject(Classifier.class).orElse(null);
// Ensure they are valid and are not the same
if (readonlySubtype == null || supertype == null || readonlySubtype == supertype) {
return Optional.empty();
}
// Rules:
// Abstract types can be extended by any type.
// Types can be extended by other types in their category
// Implementations can extend other implementations with same category and abstract implementation in some cases.
// Feature Group Types can extend other feature group types
final boolean canCreate = (readonlySubtype instanceof ComponentType && (supertype instanceof AbstractType || supertype.getClass() == readonlySubtype.getClass())) || (readonlySubtype instanceof ComponentImplementation && (supertype instanceof AbstractImplementation || supertype.getClass() == readonlySubtype.getClass())) || (readonlySubtype instanceof FeatureGroupType && supertype instanceof FeatureGroupType);
if (!canCreate) {
return Optional.empty();
}
return Operation.createSimple(ctx.getSource(), Classifier.class, subtype -> {
// Import the package if necessary
if (subtype.getNamespace() instanceof PackageSection && subtype.getNamespace().getOwner() instanceof AadlPackage && supertype.getNamespace() instanceof PackageSection && supertype.getNamespace().getOwner() instanceof AadlPackage) {
final PackageSection subtypeSection = (PackageSection) subtype.getNamespace();
final AadlPackage supertypePackage = (AadlPackage) supertype.getNamespace().getOwner();
AadlImportsUtil.addImportIfNeeded(subtypeSection, supertypePackage);
}
// Create the generalization
final Object newBo;
if (subtype instanceof ComponentType) {
final ComponentType ct = (ComponentType) subtype;
final TypeExtension te = ct.createOwnedExtension();
te.setExtended((ComponentType) supertype);
newBo = te;
} else if (subtype instanceof ComponentImplementation) {
final ComponentImplementation ci = (ComponentImplementation) subtype;
final ImplementationExtension ie = ci.createOwnedExtension();
ie.setExtended((ComponentImplementation) supertype);
newBo = ie;
} else if (subtype instanceof FeatureGroupType) {
final FeatureGroupType fgt = (FeatureGroupType) subtype;
final GroupExtension ge = fgt.createOwnedExtension();
ge.setExtended((FeatureGroupType) supertype);
newBo = ge;
} else {
return StepResult.abort();
}
return StepResultBuilder.create().showNewBusinessObject(ctx.getSource(), newBo).build();
});
}
Aggregations