Search in sources :

Example 1 with VerdictContractSubclause

use of com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause in project VERDICT by ge-high-assurance.

the class WzrdTableLoader method getStatements.

// Extract the existing statements of the current component from .aadl script
private List<Statement> getStatements(SystemTypeImpl sys) {
    List<EObject> objs = sys.eContents();
    List<Statement> stmts = new ArrayList<Statement>();
    for (int i = 0; i < objs.size(); i++) {
        if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(i)).getParsedAnnexSubclause()).getContract();
            stmts = vd.getElements();
            break;
        }
    }
    return stmts;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)

Example 2 with VerdictContractSubclause

use of com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause in project VERDICT by ge-high-assurance.

the class StatementEditor method loadExistingMissions.

// reload the system content to take care of any change saved by used in
// .aadl script in course of current Wizard session
private List<MissionInfo> loadExistingMissions(SystemTypeImpl sys) {
    List<MissionInfo> missions = new ArrayList<MissionInfo>();
    TreeIterator<EObject> tree = sys.eAllContents();
    while (tree.hasNext()) {
        EObject tmp = tree.next();
        if (tmp instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) tmp).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) tmp).getParsedAnnexSubclause()).getContract();
            List<Statement> stmts = vd.getElements();
            for (int i = 0; i < stmts.size(); i++) {
                if (stmts.get(i) instanceof CyberMissionImpl) {
                    MissionInfo newMission = new MissionInfo();
                    newMission.setMissionID(((CyberMissionImpl) stmts.get(i)).getId());
                    List<String> cyberReqs = ((CyberMissionImpl) stmts.get(i)).getCyberReqs();
                    for (int j = 0; j < cyberReqs.size(); j++) {
                        for (int k = 0; k < tableContent.size(); k++) {
                            if (tableContent.get(k).getFormulaID().equals(cyberReqs.get(j))) {
                                newMission.addToRow(k);
                            }
                        }
                    }
                    newMission.setComment(((CyberMissionImpl) stmts.get(i)).getNote());
                    newMission.setDescription(((CyberMissionImpl) stmts.get(i)).getDescription());
                    missions.add(newMission);
                }
            }
        }
    }
    return missions;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) ArrayList(java.util.ArrayList) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause) EObject(org.eclipse.emf.ecore.EObject) CyberMissionImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 3 with VerdictContractSubclause

use of com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause in project VERDICT by ge-high-assurance.

the class StatementEditor method reloadSystem.

private SystemTypeImpl reloadSystem(SystemTypeImpl sys) {
    Resource oldResource = sys.eResource();
    ResourceSetImpl resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry();
    Resource resource = resourceSet.createResource(oldResource.getURI());
    try {
        resource.load(null);
    } catch (Exception e) {
        System.out.println("Error in reloading resource while saving content by Wizard.");
        e.printStackTrace();
    }
    TreeIterator<EObject> tree = resource.getAllContents();
    while (tree.hasNext()) {
        EObject anObject = tree.next();
        if (anObject instanceof SystemTypeImpl) {
            if (((SystemTypeImpl) anObject).getFullName().equals(sys.getFullName())) {
                sys = (SystemTypeImpl) anObject;
            }
        }
        // extract the existing set of IDs that are already used------------------------------------------------------
        if (anObject instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) anObject).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) anObject).getParsedAnnexSubclause()).getContract();
            List<Statement> stmts = vd.getElements();
            for (int i = 0; i < stmts.size(); i++) {
                if (stmts.get(i) instanceof CyberMissionImpl) {
                    idSet.add(((CyberMissionImpl) stmts.get(i)).getId());
                } else if (stmts.get(i) instanceof CyberRelImpl) {
                    idSet.add(((CyberRelImpl) stmts.get(i)).getId());
                } else if (stmts.get(i) instanceof CyberReqImpl) {
                    idSet.add(((CyberReqImpl) stmts.get(i)).getId());
                }
            }
        }
    // ------------------------------------------------------------------------------------------------------------
    }
    return sys;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) CyberRelImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberRelImpl) Resource(org.eclipse.emf.ecore.resource.Resource) CyberReqImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberReqImpl) SystemTypeImpl(org.osate.aadl2.impl.SystemTypeImpl) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause) EObject(org.eclipse.emf.ecore.EObject) CyberMissionImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 4 with VerdictContractSubclause

use of com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause in project VERDICT by ge-high-assurance.

the class WzrdDashboard method composeToolTip.

// Dynamically updates tooltiptext of the buttons
private String composeToolTip(int i) {
    String str = "";
    SystemTypeImpl sys = systems.get(i);
    List<DataPort> dpList = sys.getOwnedDataPorts();
    str = str + "IN ports:\n";
    String inLine = "";
    // wrap the string into multi-line if its lengthy-------------------------
    int inLength = 0;
    for (int j = 0; j < dpList.size(); j++) {
        if (dpList.get(j).isIn()) {
            inLength = inLength + (dpList.get(j).getFullName() + ",").length();
            inLine = inLine + dpList.get(j).getFullName() + ",";
            if (inLength > 30) {
                inLength = 0;
                inLine = inLine + "\n";
            }
        }
    }
    // -------------------------------------------------------------------------
    str = str + inLine + "\n\n";
    str = str + "OUT ports:\n";
    String outLine = "";
    int outLength = 0;
    // wrap the string into multi-line if its lengthy-------------------------
    int outCount = 0;
    for (int j = 0; j < dpList.size(); j++) {
        if (dpList.get(j).isOut()) {
            outCount++;
            outLength = outLength + (dpList.get(j).getFullName() + ",").length();
            outLine = outLine + dpList.get(j).getFullName() + ",";
            if (outLength > 30) {
                outLength = 0;
                outLine = outLine + "\n";
            }
        }
    }
    // ------------------------------------------------------------------------
    List<EObject> objs = sys.eContents();
    List<Statement> stmts = new ArrayList<Statement>();
    for (int k = 0; k < objs.size(); k++) {
        if (objs.get(k) instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) objs.get(k)).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(k)).getParsedAnnexSubclause()).getContract();
            stmts = vd.getElements();
            break;
        }
    }
    str = str + outLine + "\n\n";
    if (!checkIfSystem(sys)) {
        if (stmts.size() > 0) {
            str = str + "Cyber-relations:\n";
            if (stmts.size() == outCount) {
                colorTag = 0;
            } else {
                colorTag = 0;
            }
        } else {
            str = str + "No cyber-relation defined.";
            colorTag = 2;
        }
    } else {
        if (stmts.size() > 0) {
            str = str + "Cyber-requirements:\n";
        } else {
            str = str + "No cyber-requirement defined.";
        }
    }
    for (int m = 0; m < stmts.size(); m++) {
        str = str + stmts.get(m).getId() + "\n";
    }
    return str;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) ArrayList(java.util.ArrayList) SystemTypeImpl(org.osate.aadl2.impl.SystemTypeImpl) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause) DataPort(org.osate.aadl2.DataPort) EObject(org.eclipse.emf.ecore.EObject) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 5 with VerdictContractSubclause

use of com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause in project VERDICT by ge-high-assurance.

the class ChangeInFile method getStatements.

// extracts the existing annex-statements in the component "sys" on .aadl script
private List<Statement> getStatements(SystemTypeImpl sys) {
    List<EObject> objs = sys.eContents();
    List<Statement> stmts = new ArrayList<Statement>();
    for (int i = 0; i < objs.size(); i++) {
        if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(i)).getParsedAnnexSubclause()).getContract();
            stmts = vd.getElements();
            break;
        }
    }
    return stmts;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)

Aggregations

Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)5 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)5 VerdictContractSubclause (com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)5 EObject (org.eclipse.emf.ecore.EObject)5 DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)5 ArrayList (java.util.ArrayList)4 CyberMissionImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl)2 SystemTypeImpl (org.osate.aadl2.impl.SystemTypeImpl)2 CyberRelImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberRelImpl)1 CyberReqImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberReqImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 DataPort (org.osate.aadl2.DataPort)1