Search in sources :

Example 1 with CyberMissionImpl

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

the class ChangeInFile method loadOffsetLength.

// finds the offsets of annex statements as on the .aadl script
private void loadOffsetLength(List<Statement> stmts) {
    DefaultLocationInFileProvider defLoc = new DefaultLocationInFileProvider();
    List<Integer> tmpOffset = new ArrayList<Integer>();
    List<Integer> tmpLength = new ArrayList<Integer>();
    for (int i = 0; i < stmts.size(); i++) {
        if (stmts.get(i) instanceof CyberMissionImpl) {
            ITextRegion region = defLoc.getFullTextRegion(stmts.get(i));
            tmpOffset.add(region.getOffset());
            tmpLength.add(region.getLength());
            missionTags.add(true);
            continue;
        }
        for (int j = 0; j < deleteContents.size(); j++) {
            if (stmts.get(i).getId().equals(deleteContents.get(j).getFormulaID())) {
                missionTags.add(false);
                ITextRegion region = defLoc.getFullTextRegion(stmts.get(i));
                tmpOffset.add(region.getOffset());
                tmpLength.add(region.getLength());
            }
        }
    }
    offsets = tmpOffset;
    offsets.sort(null);
    for (int i = 0; i < offsets.size(); i++) {
        for (int j = 0; j < tmpOffset.size(); j++) {
            if (offsets.get(i) == tmpOffset.get(j)) {
                lengths.add(tmpLength.get(j));
            }
        }
    }
}
Also used : DefaultLocationInFileProvider(org.eclipse.xtext.resource.DefaultLocationInFileProvider) ITextRegion(org.eclipse.xtext.util.ITextRegion) ArrayList(java.util.ArrayList) CyberMissionImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl)

Example 2 with CyberMissionImpl

use of com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl 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 CyberMissionImpl

use of com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl 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)

Aggregations

CyberMissionImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl)3 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)2 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)2 VerdictContractSubclause (com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)2 ArrayList (java.util.ArrayList)2 EObject (org.eclipse.emf.ecore.EObject)2 DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)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 DefaultLocationInFileProvider (org.eclipse.xtext.resource.DefaultLocationInFileProvider)1 ITextRegion (org.eclipse.xtext.util.ITextRegion)1 SystemTypeImpl (org.osate.aadl2.impl.SystemTypeImpl)1