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));
}
}
}
}
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;
}
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;
}
Aggregations