Search in sources :

Example 76 with ComponentType

use of org.geotoolkit.sml.xml.v100.ComponentType in project AGREE by loonwerks.

the class AgreeValidator method checkAssign.

@Check(CheckType.FAST)
public void checkAssign(AssignStatement assign) {
    if (!(assign.getId() instanceof NamedElement)) {
        error(assign.getId(), "The Id on the left hand side of an assignment statement " + "must not contain a \".\"");
        return;
    }
    NamedElement namedEl = assign.getId();
    Expr expr = assign.getExpr();
    if (namedEl == null || expr == null) {
        return;
    }
    ComponentImplementation compImpl = EcoreUtil2.getContainerOfType(assign, ComponentImplementation.class);
    if (compImpl == null) {
        error(assign, "Assignment statements are allowed only in component implementations");
        return;
    }
    if (namedEl.eContainer() instanceof InputStatement) {
        error(assign, "Assignment to agree_input variables is illegal.");
        return;
    }
    if (compImpl != null) {
        List<EObject> assignableElements = new ArrayList<>();
        List<AgreeContract> implContracts = EcoreUtil2.getAllContentsOfType(compImpl, AgreeContract.class);
        for (AgreeContract ac : implContracts) {
            assignableElements.addAll(EcoreUtil2.getAllContentsOfType(ac, EqStatement.class).stream().map(eq -> eq.getLhs()).flatMap(List::stream).collect(Collectors.toList()));
        }
        ComponentType compType = compImpl.getType();
        if (compType != null) {
            List<AgreeContract> typeContracts = EcoreUtil2.getAllContentsOfType(compType, AgreeContract.class);
            for (AgreeContract ac : typeContracts) {
                assignableElements.addAll(EcoreUtil2.getAllContentsOfType(ac, EqStatement.class).stream().map(eq -> eq.getLhs()).flatMap(List::stream).collect(Collectors.toList()));
            }
        }
        assignableElements.addAll(compImpl.getAllFeatures().stream().map(cf -> flattenFeatureGroups(Collections.singletonList(cf))).flatMap(List::stream).filter(feat -> feat instanceof EventDataPort || feat instanceof DataPort).filter(feat -> DirectionType.OUT.equals(((Port) feat).getDirection())).collect(Collectors.toList()));
        if (!assignableElements.contains(namedEl)) {
            error("LHS of assignment must be an AGREE 'eq' variable or an output port of this component", assign, AgreePackage.Literals.ASSIGN_STATEMENT__ID);
        }
    }
    TypeDef lhsType = (AgreeTypeSystem.inferFromNamedElement(namedEl));
    TypeDef rhsType = (AgreeTypeSystem.infer(expr));
    if (!AgreeTypeSystem.typesEqual(lhsType, rhsType)) {
        error(assign, "The left hand side of the assignment statement is of type '" + nameOfTypeDef(lhsType) + "' but the right hand side is of type '" + nameOfTypeDef(rhsType) + "'");
    }
    for (EObject container : EcoreUtil2.getAllContainers(assign)) {
        if (container instanceof Classifier) {
            for (AnnexSubclause annexSubclause : AnnexUtil.getAllAnnexSubclauses((Classifier) container, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
                for (AgreeContract contract : EcoreUtil2.getAllContentsOfType(annexSubclause, AgreeContract.class)) {
                    if (contract != null) {
                        for (SpecStatement spec : contract.getSpecs()) {
                            if (spec instanceof AssignStatement && spec != assign) {
                                NamedElement otherEl = ((AssignStatement) spec).getId();
                                if (otherEl.equals(namedEl)) {
                                    error(spec, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                    error(assign, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                }
                            } else if (spec instanceof EqStatement) {
                                EqStatement eqStmt = (EqStatement) spec;
                                for (NamedElement otherEl : eqStmt.getLhs()) {
                                    if (eqStmt.getExpr() != null && otherEl.equals(namedEl)) {
                                        error(spec, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                        error(assign, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) AnnexUtil(org.osate.annexsupport.AnnexUtil) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Map(java.util.Map) OrderStatement(com.rockwellcollins.atc.agree.agree.OrderStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) BigInteger(java.math.BigInteger) Check(org.eclipse.xtext.validation.Check) WheneverOccursStatement(com.rockwellcollins.atc.agree.agree.WheneverOccursStatement) CalenStatement(com.rockwellcollins.atc.agree.agree.CalenStatement) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) SporadicStatement(com.rockwellcollins.atc.agree.agree.SporadicStatement) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) Set(java.util.Set) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) AadlPackage(org.osate.aadl2.AadlPackage) MNSynchStatement(com.rockwellcollins.atc.agree.agree.MNSynchStatement) ModelUnit(org.osate.aadl2.ModelUnit) ConnectionStatement(com.rockwellcollins.atc.agree.agree.ConnectionStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) TimeInterval(com.rockwellcollins.atc.agree.agree.TimeInterval) DataType(org.osate.aadl2.DataType) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) Feature(org.osate.aadl2.Feature) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) CheckType(org.eclipse.xtext.validation.CheckType) LiftContractStatement(com.rockwellcollins.atc.agree.agree.LiftContractStatement) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) AgreeAADLEnumerationUtils(com.rockwellcollins.atc.agree.AgreeAADLEnumerationUtils) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FeatureGroup(org.osate.aadl2.FeatureGroup) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) ReachableStatement(com.rockwellcollins.atc.agree.agree.ReachableStatement) PropertyConstant(org.osate.aadl2.PropertyConstant) EventPort(org.osate.aadl2.EventPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FeatureGroupType(org.osate.aadl2.FeatureGroupType) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) DataPort(org.osate.aadl2.DataPort) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) PeriodicStatement(com.rockwellcollins.atc.agree.agree.PeriodicStatement) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) AnnexSubclause(org.osate.aadl2.AnnexSubclause) NamedElement(org.osate.aadl2.NamedElement) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) NodeStmt(com.rockwellcollins.atc.agree.agree.NodeStmt) DataImplementation(org.osate.aadl2.DataImplementation) AsynchStatement(com.rockwellcollins.atc.agree.agree.AsynchStatement) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) AgreeContractLibrary(com.rockwellcollins.atc.agree.agree.AgreeContractLibrary) Port(org.osate.aadl2.Port) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) HashMultimap(com.google.common.collect.HashMultimap) Classifier(org.osate.aadl2.Classifier) ComponentType(org.osate.aadl2.ComponentType) Type(com.rockwellcollins.atc.agree.agree.Type) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) AssertStatement(com.rockwellcollins.atc.agree.agree.AssertStatement) NodeEq(com.rockwellcollins.atc.agree.agree.NodeEq) NodeLemma(com.rockwellcollins.atc.agree.agree.NodeLemma) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) Collectors(java.util.stream.Collectors) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) List(java.util.List) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Property(org.osate.aadl2.Property) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) SynchStatement(com.rockwellcollins.atc.agree.agree.SynchStatement) AnnexLibrary(org.osate.aadl2.AnnexLibrary) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) WhenHoldsStatement(com.rockwellcollins.atc.agree.agree.WhenHoldsStatement) FloorCast(com.rockwellcollins.atc.agree.agree.FloorCast) HashMap(java.util.HashMap) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) Expr(com.rockwellcollins.atc.agree.agree.Expr) HashSet(java.util.HashSet) DataSubcomponent(org.osate.aadl2.DataSubcomponent) InitialStatement(com.rockwellcollins.atc.agree.agree.InitialStatement) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DirectionType(org.osate.aadl2.DirectionType) WheneverBecomesTrueStatement(com.rockwellcollins.atc.agree.agree.WheneverBecomesTrueStatement) ExprCycleVisitor(com.rockwellcollins.atc.agree.visitors.ExprCycleVisitor) LinkedList(java.util.LinkedList) PropertyStatement(com.rockwellcollins.atc.agree.agree.PropertyStatement) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) Iterator(java.util.Iterator) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) EList(org.eclipse.emf.common.util.EList) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) EventDataPort(org.osate.aadl2.EventDataPort) LinearizationInterval(com.rockwellcollins.atc.agree.agree.LinearizationInterval) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) WheneverImpliesStatement(com.rockwellcollins.atc.agree.agree.WheneverImpliesStatement) WheneverHoldsStatement(com.rockwellcollins.atc.agree.agree.WheneverHoldsStatement) Abstraction(com.rockwellcollins.atc.agree.agree.Abstraction) WhenOccursStatment(com.rockwellcollins.atc.agree.agree.WhenOccursStatment) Collections(java.util.Collections) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ComponentType(org.osate.aadl2.ComponentType) EventPort(org.osate.aadl2.EventPort) DataPort(org.osate.aadl2.DataPort) Port(org.osate.aadl2.Port) EventDataPort(org.osate.aadl2.EventDataPort) ArrayList(java.util.ArrayList) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Check(org.eclipse.xtext.validation.Check)

Example 77 with ComponentType

use of org.geotoolkit.sml.xml.v100.ComponentType in project AGREE by loonwerks.

the class AgreeValidator method checkInitialStatement.

@Check(CheckType.FAST)
public void checkInitialStatement(InitialStatement statement) {
    Classifier comp = statement.getContainingClassifier();
    if (!(comp instanceof ComponentType)) {
        error(statement, "Initial statements are allowed only in component types");
    }
    TypeDef exprType = AgreeTypeSystem.infer(statement.getExpr());
    if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, exprType)) {
        error(statement, "Expression for 'initially' statement is of type '" + nameOfTypeDef(exprType) + "' but must be of type 'bool'");
    }
}
Also used : ComponentType(org.osate.aadl2.ComponentType) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Check(org.eclipse.xtext.validation.Check)

Example 78 with ComponentType

use of org.geotoolkit.sml.xml.v100.ComponentType in project AGREE by loonwerks.

the class AgreeValidator method getParentNames.

private Set<String> getParentNames(ComponentImplementation ci) {
    Set<String> result = new HashSet<>();
    ComponentType ct = ci.getType();
    for (AgreeSubclause subclause : EcoreUtil2.getAllContentsOfType(ct, AgreeSubclause.class)) {
        List<NamedElement> es = EcoreUtil2.getAllContentsOfType(subclause, NamedElement.class);
        for (NamedElement e : es) {
            if (!(e.eContainer() instanceof NodeDef || e.eContainer() instanceof LinearizationDef || e.eContainer() instanceof RecordDef || e instanceof NamedSpecStatement)) {
                result.add(e.getName());
            }
        }
    }
    return result;
}
Also used : AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) ComponentType(org.osate.aadl2.ComponentType) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) NamedElement(org.osate.aadl2.NamedElement) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) HashSet(java.util.HashSet)

Example 79 with ComponentType

use of org.geotoolkit.sml.xml.v100.ComponentType in project geotoolkit by Geomatys.

the class SmlXMLFactory method convertTo101.

public static org.geotoolkit.sml.xml.v101.SensorML convertTo101(final org.geotoolkit.sml.xml.v100.SensorML sensor) {
    List<org.geotoolkit.sml.xml.v101.SensorML.Member> newMembers = new ArrayList<org.geotoolkit.sml.xml.v101.SensorML.Member>();
    for (Member oldMember : sensor.getMember()) {
        final org.geotoolkit.sml.xml.v101.AbstractProcessType newProcess;
        if (oldMember.getRealProcess() instanceof System) {
            newProcess = new org.geotoolkit.sml.xml.v101.SystemType();
        } else if (oldMember.getRealProcess() instanceof Component) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentType();
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            newProcess = new org.geotoolkit.sml.xml.v101.DataSourceType();
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            newProcess = new org.geotoolkit.sml.xml.v101.ProcessModelType();
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentArrayType();
        } else {
            throw new IllegalArgumentException("Other sensor type than system, component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        AbstractProcessType oldProcess = (AbstractProcessType) oldMember.getRealProcess();
        // id
        newProcess.setId(oldProcess.getId());
        // name
        newProcess.setName(oldProcess.getName());
        // srsName
        newProcess.setSrsName(oldProcess.getSrsName());
        // description
        newProcess.setDescription(oldProcess.getDescription());
        // boundedBy
        newProcess.setBoundedBy(oldProcess.getBoundedBy());
        // capabilities
        List<org.geotoolkit.sml.xml.v101.Capabilities> newCapabilities = new ArrayList<org.geotoolkit.sml.xml.v101.Capabilities>();
        for (Capabilities oldCapa : oldProcess.getCapabilities()) {
            newCapabilities.add(new org.geotoolkit.sml.xml.v101.Capabilities(oldCapa));
        }
        newProcess.setCapabilities(newCapabilities);
        // characteristics
        List<org.geotoolkit.sml.xml.v101.Characteristics> newCharacteristics = new ArrayList<org.geotoolkit.sml.xml.v101.Characteristics>();
        for (Characteristics oldChar : oldProcess.getCharacteristics()) {
            newCharacteristics.add(new org.geotoolkit.sml.xml.v101.Characteristics(oldChar));
        }
        newProcess.setCharacteristics(newCharacteristics);
        // Classification
        List<org.geotoolkit.sml.xml.v101.Classification> newClassification = new ArrayList<org.geotoolkit.sml.xml.v101.Classification>();
        for (Classification oldClass : oldProcess.getClassification()) {
            newClassification.add(new org.geotoolkit.sml.xml.v101.Classification(oldClass));
        }
        newProcess.setClassification(newClassification);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Contact> newContact = new ArrayList<org.geotoolkit.sml.xml.v101.Contact>();
        for (Contact oldContact : oldProcess.getContact()) {
            newContact.add(new org.geotoolkit.sml.xml.v101.Contact(oldContact));
        }
        newProcess.setContact(newContact);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Documentation> newDocumentation = new ArrayList<org.geotoolkit.sml.xml.v101.Documentation>();
        for (Documentation oldDoc : oldProcess.getDocumentation()) {
            newDocumentation.add(new org.geotoolkit.sml.xml.v101.Documentation(oldDoc));
        }
        newProcess.setDocumentation(newDocumentation);
        // History
        List<org.geotoolkit.sml.xml.v101.History> newHistory = new ArrayList<org.geotoolkit.sml.xml.v101.History>();
        for (History oldhist : oldProcess.getHistory()) {
            newHistory.add(new org.geotoolkit.sml.xml.v101.History(oldhist));
        }
        newProcess.setHistory(newHistory);
        // Identification
        List<org.geotoolkit.sml.xml.v101.Identification> newIdentification = new ArrayList<org.geotoolkit.sml.xml.v101.Identification>();
        for (Identification oldIdent : oldProcess.getIdentification()) {
            newIdentification.add(new org.geotoolkit.sml.xml.v101.Identification(oldIdent));
        }
        newProcess.setIdentification(newIdentification);
        // keywords
        List<org.geotoolkit.sml.xml.v101.Keywords> newKeywords = new ArrayList<org.geotoolkit.sml.xml.v101.Keywords>();
        for (Keywords oldKeyw : oldProcess.getKeywords()) {
            newKeywords.add(new org.geotoolkit.sml.xml.v101.Keywords(oldKeyw));
        }
        newProcess.setKeywords(newKeywords);
        // legal constraint
        List<org.geotoolkit.sml.xml.v101.LegalConstraint> newLegalConstraints = new ArrayList<org.geotoolkit.sml.xml.v101.LegalConstraint>();
        for (LegalConstraint oldcons : oldProcess.getLegalConstraint()) {
            newLegalConstraints.add(new org.geotoolkit.sml.xml.v101.LegalConstraint(oldcons));
        }
        newProcess.setLegalConstraint(newLegalConstraints);
        // security constraint
        if (oldProcess.getSecurityConstraint() != null) {
            newProcess.setSecurityConstraint(new org.geotoolkit.sml.xml.v101.SecurityConstraint(oldProcess.getSecurityConstraint()));
        }
        // validTime
        if (oldProcess.getValidTime() != null) {
            newProcess.setValidTime(oldProcess.getValidTime());
        }
        if (oldProcess instanceof AbstractComponent) {
            AbstractComponent newAbsComponent = (AbstractComponent) newProcess;
            AbstractComponent oldAbsComponent = (AbstractComponent) oldProcess;
            // Inputs
            if (oldAbsComponent.getInputs() != null) {
                newAbsComponent.setInputs(oldAbsComponent.getInputs());
            }
            // outputs
            if (oldAbsComponent.getOutputs() != null) {
                newAbsComponent.setOutputs(oldAbsComponent.getOutputs());
            }
            // parameters
            if (oldAbsComponent.getParameters() != null) {
                newAbsComponent.setParameters(oldAbsComponent.getParameters());
            }
        }
        if (oldProcess instanceof AbstractDerivableComponent) {
            org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType newDerComponent = (org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType) newProcess;
            AbstractDerivableComponent oldDerComponent = (AbstractDerivableComponent) oldProcess;
            // Position
            if (oldDerComponent.getPosition() != null) {
                newDerComponent.setPosition(oldDerComponent.getPosition());
            }
            if (oldDerComponent.getSMLLocation() != null) {
                newDerComponent.setSMLLocation(oldDerComponent.getSMLLocation());
            }
            if (oldDerComponent.getInterfaces() != null) {
                newDerComponent.setInterfaces(new org.geotoolkit.sml.xml.v101.Interfaces(oldDerComponent.getInterfaces()));
            }
            if (oldDerComponent.getSpatialReferenceFrame() != null) {
                newDerComponent.setSpatialReferenceFrame(new org.geotoolkit.sml.xml.v101.SpatialReferenceFrame(oldDerComponent.getSpatialReferenceFrame()));
            }
            if (oldDerComponent.getTemporalReferenceFrame() != null) {
                newDerComponent.setTemporalReferenceFrame(new org.geotoolkit.sml.xml.v101.TemporalReferenceFrame(oldDerComponent.getTemporalReferenceFrame()));
            }
            if (oldDerComponent.getTimePosition() != null) {
                newDerComponent.setTimePosition(new org.geotoolkit.sml.xml.v101.TimePosition(oldDerComponent.getTimePosition()));
            }
        }
        if (oldProcess instanceof AbstractPureProcess) {
            org.geotoolkit.sml.xml.v101.AbstractPureProcessType newAbsPuProc = (org.geotoolkit.sml.xml.v101.AbstractPureProcessType) newProcess;
            AbstractPureProcess oldAbsPuProc = (AbstractPureProcess) oldProcess;
            // Inputs
            if (oldAbsPuProc.getInputs() != null) {
                newAbsPuProc.setInputs(new org.geotoolkit.sml.xml.v101.Inputs(oldAbsPuProc.getInputs()));
            }
            // outputs
            if (oldAbsPuProc.getOutputs() != null) {
                newAbsPuProc.setOutputs(new org.geotoolkit.sml.xml.v101.Outputs(oldAbsPuProc.getOutputs()));
            }
            // parameters
            if (oldAbsPuProc.getParameters() != null) {
                newAbsPuProc.setParameters(new org.geotoolkit.sml.xml.v101.Parameters(oldAbsPuProc.getParameters()));
            }
        }
        if (oldMember.getRealProcess() instanceof System) {
            SystemType oldSystem = (SystemType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.SystemType newSystem = (org.geotoolkit.sml.xml.v101.SystemType) newProcess;
            // components
            if (oldSystem.getComponents() != null) {
                newSystem.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldSystem.getComponents()));
            }
            // positions
            if (oldSystem.getPositions() != null) {
                newSystem.setPositions(new org.geotoolkit.sml.xml.v101.Positions(oldSystem.getPositions()));
            }
            // connections
            if (oldSystem.getConnections() != null) {
                newSystem.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldSystem.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof Component) {
            ComponentType oldComponent = (ComponentType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ComponentType newCompo = (org.geotoolkit.sml.xml.v101.ComponentType) newProcess;
            // method
            if (oldComponent.getMethod() != null) {
                newCompo.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldComponent.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            DataSourceType oldDataSource = (DataSourceType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.DataSourceType newDataSource = (org.geotoolkit.sml.xml.v101.DataSourceType) newProcess;
            if (oldDataSource.getDataDefinition() != null) {
                newDataSource.setDataDefinition(new org.geotoolkit.sml.xml.v101.DataDefinition(oldDataSource.getDataDefinition()));
            }
            if (oldDataSource.getValues() != null) {
                newDataSource.setValues(new org.geotoolkit.sml.xml.v101.Values(oldDataSource.getValues()));
            }
            if (oldDataSource.getObservationReference() != null) {
                newDataSource.setObservationReference(new org.geotoolkit.sml.xml.v101.ObservationReference(oldDataSource.getObservationReference()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            ProcessModelType oldProcessModel = (ProcessModelType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessModelType newProcessModel = (org.geotoolkit.sml.xml.v101.ProcessModelType) newProcess;
            if (oldProcessModel.getMethod() != null) {
                newProcessModel.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldProcessModel.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessChain) {
            ProcessChainType oldProcessChain = (ProcessChainType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessChainType newProcessChain = (org.geotoolkit.sml.xml.v101.ProcessChainType) newProcess;
            // components
            if (oldProcessChain.getComponents() != null) {
                newProcessChain.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldProcessChain.getComponents()));
            }
            // connections
            if (oldProcessChain.getConnections() != null) {
                newProcessChain.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldProcessChain.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
        // nothing to do
        } else {
            throw new IllegalArgumentException("Other sensor type than system ,component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        newMembers.add(new org.geotoolkit.sml.xml.v101.SensorML.Member(newProcess));
    }
    org.geotoolkit.sml.xml.v101.SensorML result = new org.geotoolkit.sml.xml.v101.SensorML("1.0.1", newMembers);
    return result;
}
Also used : ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v100.SystemType) History(org.geotoolkit.sml.xml.v100.History) Classification(org.geotoolkit.sml.xml.v100.Classification) DataSourceType(org.geotoolkit.sml.xml.v100.DataSourceType) Member(org.geotoolkit.sml.xml.v100.Member) Documentation(org.geotoolkit.sml.xml.v100.Documentation) AbstractProcessType(org.geotoolkit.sml.xml.v100.AbstractProcessType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) LegalConstraint(org.geotoolkit.sml.xml.v100.LegalConstraint) Identification(org.geotoolkit.sml.xml.v100.Identification) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) Contact(org.geotoolkit.sml.xml.v100.Contact) Characteristics(org.geotoolkit.sml.xml.v100.Characteristics) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) ProcessModelType(org.geotoolkit.sml.xml.v100.ProcessModelType) ProcessChainType(org.geotoolkit.sml.xml.v100.ProcessChainType)

Example 80 with ComponentType

use of org.geotoolkit.sml.xml.v100.ComponentType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method marshallMarshalingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void marshallMarshalingTest() throws Exception {
    ObjectFactory factory = new ObjectFactory();
    List<DataComponentPropertyType> fields = new ArrayList<DataComponentPropertyType>();
    TimeType time = new TimeType("urn:x-ogc:def:phenomenon:observationTime", new UomPropertyType(null, "urn:x-ogc:def:unit:ISO8601"));
    fields.add(new DataComponentPropertyType("time", null, time));
    QuantityType q = new QuantityType("urn:x-ogc:def:phenomenon:OGC:depth", new UomPropertyType("m", null), null);
    fields.add(new DataComponentPropertyType("depth", null, q));
    BooleanType b = new BooleanType("urn:x-ogc:def:phenomenon:BRGM:validity", null);
    fields.add(new DataComponentPropertyType("validity", null, b));
    DataRecordType outRecord = new DataRecordType(null, fields);
    IoComponentPropertyType io2 = new IoComponentPropertyType("piezoMeasurements", swe100Factory.createDataRecord(outRecord));
    OutputList outputList = new OutputList(Arrays.asList(io2));
    Outputs outputs = new Outputs(outputList);
    Marshaller marshaller = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    StringWriter sw = new StringWriter();
    marshaller.marshal(outputs, sw);
    String result = sw.toString();
    // System.out.println("result:" + result);
    ComponentType component = new ComponentType();
    ProcessMethodType process = new ProcessMethodType();
    component.setMethod(new MethodPropertyType(process));
    List<ComponentPropertyType> cpl = new ArrayList<ComponentPropertyType>();
    ComponentList cl = new ComponentList(cpl);
    sw = new StringWriter();
    marshaller.marshal(factory.createComponent(component), sw);
    result = sw.toString();
    // System.out.println("result:" + result);
    SensorMLMarshallerPool.getInstance().recycle(marshaller);
}
Also used : DataRecordType(org.geotoolkit.swe.xml.v100.DataRecordType) AbstractDataRecordType(org.geotoolkit.swe.xml.v100.AbstractDataRecordType) Marshaller(javax.xml.bind.Marshaller) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) ComponentPropertyType(org.geotoolkit.sml.xml.v100.ComponentPropertyType) ArrayList(java.util.ArrayList) BooleanType(org.geotoolkit.swe.xml.v100.BooleanType) ComponentList(org.geotoolkit.sml.xml.v100.ComponentList) ProcessMethodType(org.geotoolkit.sml.xml.v100.ProcessMethodType) IoComponentPropertyType(org.geotoolkit.sml.xml.v100.IoComponentPropertyType) MethodPropertyType(org.geotoolkit.sml.xml.v100.MethodPropertyType) TimeType(org.geotoolkit.swe.xml.v100.TimeType) UomPropertyType(org.geotoolkit.swe.xml.v100.UomPropertyType) ObjectFactory(org.geotoolkit.sml.xml.v100.ObjectFactory) StringWriter(java.io.StringWriter) QuantityType(org.geotoolkit.swe.xml.v100.QuantityType) Outputs(org.geotoolkit.sml.xml.v100.Outputs) DataComponentPropertyType(org.geotoolkit.swe.xml.v100.DataComponentPropertyType) OutputList(org.geotoolkit.sml.xml.v100.OutputList)

Aggregations

ComponentType (org.osate.aadl2.ComponentType)73 ComponentImplementation (org.osate.aadl2.ComponentImplementation)42 Classifier (org.osate.aadl2.Classifier)33 ComponentClassifier (org.osate.aadl2.ComponentClassifier)21 ArrayList (java.util.ArrayList)18 EObject (org.eclipse.emf.ecore.EObject)16 NamedElement (org.osate.aadl2.NamedElement)15 AnnexSubclause (org.osate.aadl2.AnnexSubclause)13 Feature (org.osate.aadl2.Feature)13 BasicEList (org.eclipse.emf.common.util.BasicEList)11 AadlPackage (org.osate.aadl2.AadlPackage)11 HashSet (java.util.HashSet)10 FeatureGroupType (org.osate.aadl2.FeatureGroupType)10 List (java.util.List)9 Subcomponent (org.osate.aadl2.Subcomponent)8 FeatureGroup (org.osate.aadl2.FeatureGroup)7 EList (org.eclipse.emf.common.util.EList)6 Property (org.osate.aadl2.Property)6 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)6 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)5