Exemplo n.º 1
0
def Summary(package,profile,check,fullReport):
    stpC=StereotypesHelper.getStereotypesByProfile(profile)
    csPack=ControlServiceFind(package,profile, stpC)
    if csPack==None:
            gl.log("******ERROR*****The Validation Package is not found in the CS=======>"+package.getName())
    else:
        [elemCount,genCount,diagCount,diagError,elemError,packError,genError,redefError,redefWarning,goodElem,goodRedef,goodGen,goodDiag,goodPack,instElem,csElems,redefCS,insProp,insPropT1,insPropT2,insPropT3,insPropT4,sysModels,sysTls]=FixPackage.blah(package,csPack, profile, check,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,{},0,{},{},{},{},{},{},{},0,{},{})
        gl.log("--------------------------Summary Elements Report--------------------------")
        gl.log("Instance Elements Found===============>"+str(len(instElem)))
        gl.log("CS Elements Found===============>"+str(csElems))
        gl.log("Elements Found Matching===============>"+str(goodElem))
        gl.log("Packages Found===========>"+str(goodPack))
        gl.log("Generalizations===============>"+str(goodGen))
        gl.log("Diagrams Found==============>"+str(goodDiag))
        gl.log("Redefinitions Found==============>"+str(len(redefCS)))
        gl.log("Properties Found========>"+ str(len(insProp)))
                
        gl.log("--------------------------Summary Error Report--------------------------")
        gl.log("More Elements in CS Not Instance Found===============>"+str(elemError))
        MoreIns=len(instElem)-goodElem
        if MoreIns!=0:
            gl.log("More Elements Found in the Instance than the CS =======>"+str(MoreIns))
        gl.log("Packages Not Found===========>"+str(packError))
        gl.log("Elements without Generalization===============>"+str(genError))
        gl.log("Diagram Not Found===============>"+str(diagError))
        gl.log("Attribute is not redefined or stereotyped"+str(len(insPropT3)))
        gl.log("Redefinition Error/Warning Total =======>"+str(len(insProp)-len(redefCS)))
        gl.log("--------------------------Summary Warning Report--------------------------")
        gl.log("Element Redefined but Redefinition is found in different MSAF Model Element======>"+str(len(insPropT1)))
        gl.log("Attribute Element matched MSAF Attribute Element Stereotype, but no redefinition Defined======>"+str(len(insPropT2)))
        gl.log("Element Redefined, but missing appropriate Stereotype======>"+str(len(insPropT4)))
        gl.log("--------------------------Summary Creation Report Report--------------------------")
        gl.log("Elements Created===============>"+str(elemCount))
        gl.log("Generalizations Created===========>"+str(genCount))
        gl.log("Diagrams Created===============>"+str(diagCount))
        gl.log("--------------------------Summary Fix Me! Elements--------------------------")
        
        ##NEED TO REMOVE Question Asking##
        [count,Fixes]=FixPackage.countFixes(0,[],package)
#        gl.log("The total number of fix me elements===>"+str(count))
#        n = JOptionPane.showConfirmDialog(None,"Do you want to view the name of the Elements that still contains Fix Me!??","View Name Question", JOptionPane.YES_NO_OPTION)
#        if n!=JOptionPane.CLOSED_OPTION:
#            if n==JOptionPane.YES_OPTION:
#                for j in Fixes:
#                    gl.log("The name of the element to fix is:========>"+j.getName())
#        gl.log("--------------------------Summary Stereotypes Report--------------------------")
#        q = JOptionPane.showConfirmDialog(None,"Do you want to view the Stereotype Summary??","Stereotype Question", JOptionPane.YES_NO_OPTION)
#        if q!=JOptionPane.CLOSED_OPTION:
#            if q==JOptionPane.YES_OPTION:
#                Fix_Package.stereotypeReport(CSst,package)
        
        frmwrkVal = StereotypesHelper.getStereotype(project, 'FrameworkImplValidation.ValidatePackage')
        frmwrkDes = frmwrkVal.getOwnedComment()[0].getBody()
        output.append(DBParagraph(frmwrkDes))
        
        output.append(DBParagraph("--------------------------Model INFORMATION Report--------------------------"))
        table = DBTable()
        table.setBody([[DBText("Service Implementation Elements Found"),DBText(str(len(instElem)))],
                       [DBText("MSAF Elements Found (in matching location)"),DBText(str(csElems))],
                       [DBText("Elements Found Matching (between Service Implementation and MSAF)"),DBText(str(goodElem))],
                       [DBText("Service Implementation Packages Found"),DBText(str(goodPack))],
                       [DBText("Generalizations Found"),DBText(str(goodGen))],
                       [DBText("Diagrams Found"),DBText(str(goodDiag))],
                       [DBText("Redefinitions Found"),DBText(str(len(redefCS)))],
                       [DBText("Properties Found"),DBText(str(len(insProp)))]])
        table.setHeaders([[DBText("Model Elements"),DBText("Count")]])
        table.setTitle("Model Information Report")
        table.setCols(2)
        output.append(table)
        
        output.append(DBParagraph("--------------------------Model ERROR Report--------------------------"))
        table = DBTable()
        table.setBody([[DBText("MSAF Comparison Validation"),DBText("Elements in MSAF not found in Service Implementation"),DBText(str(elemError))],
                       [DBText("MSAF Comparison Validation"),DBText("More Elements in Service Implementation then MSAF"),DBText(str(MoreIns))],
                       [DBText("MSAF Comparison Validation"),DBText("Packages Not Found"),DBText(str(packError))],
                       [DBText("MSAF Comparison Validation"),DBText("Elements without generalization"),DBText(str(genError))],
                       [DBText("MSAF Comparison Validation"),DBText("Diagram Not Found"),DBText(str(diagError))],
                       [DBText("MSAF Comparison Validation"),DBText("Redefinition Error: Property is Not Redefined or Stereotyped"),DBText(str(len(insPropT3)))],
                       [DBText("MSAF Comparison Validation"),DBText("Total Redefinition Error/Warning"),DBText(str(len(insProp)-len(redefCS)))]])
#                       [DBText("MSAF Comparison Validation"),DBText("Redefinition Defined but No Stereotype on Part"),DBText(str(len(insPropT1)-len(redefCS)))],
#                       [DBText("MSAF Comparison Validation"),DBText("Redefinition Defined but No Stereotype on Part"),DBText(str(len(insPropT2)-len(redefCS)))]])
        table.setHeaders([[DBText("Validation Suite"),DBText("Error Type"),DBText("Count")]])
        table.setTitle("Model Errors Report")
        table.setCols(3)
        output.append(table)


        output.append(DBParagraph("--------------------------Model Warning Report--------------------------"))
        table = DBTable()
        table.setBody([[DBText("MSAF Comparison Validation"),DBText("Redefinition Warning:  Element Redefined but Redefinition is found in different MSAF Model Element"),DBText(str(len(insPropT1)))],
                       [DBText("MSAF Comparison Validation"),DBText("Redefinition Warning:  Service Implementation Property matched MSAF Property Element Stereotype, but no redefinition Defined"),DBText(str(len(insPropT2)))],
                       [DBText("MSAF Comparison Validation"),DBText("Redefinition Warning:  Element Redefined, but missing appropriate Stereotype"),DBText(str(len(insPropT4)))]])

        
        table.setHeaders([[DBText("Validation Suite"),DBText("Warning Type"),DBText("Count")]])
        table.setTitle("Model Warnings Report")
        table.setCols(3)
        output.append(table)
    
        
        
        if fullReport==True:
            output.append(DBParagraph("--------------------------Summary Redefinitions Errors/Warning--------------------------"))
            
            gl.log("--------------------------Summary Redefinition Not Correct--------------------------")
            gl.log("-------Total of the different Errors----should match redef error---"+str(len(insPropT1)+len(insPropT2)+len(insPropT3)+len(insPropT4)))
            gl.log(" the length of the insPropT1??====>"+str(len(insPropT1)))
            
            output.append(DBParagraph("--------------------------REDEFINITION WARNING: Element Redefined but Redefinition is found in different MSAF Model Element--------------------------"))
            for m in insPropT1:
                gl.log("Property not found in the correct MSAF Element=====>"+m.getQualifiedName())
                output.append(DBParagraph(m.getQualifiedName()))
            output.append(DBParagraph("--------------------------REDEFINITION WARNING: Service Implementation Property matched MSAF Property Element Stereotype, but no redefinition Defined--------------------------"))
            for n in insPropT2:
                gl.log("Service Implementation Property matched MSAF Property Element Stereotype, but no redefinition Defined=====>"+n.getQualifiedName())
                output.append(DBParagraph(n.getQualifiedName()))
            output.append(DBParagraph("--------------------------REDEFINITION WARNING: Service Implementation Property has redefinition, but no Stereotype--------------------------"))
            for q in insPropT4:
                gl.log("This part is redefined, but not stereotyped"+q.getQualifiedName())
                output.append(DBParagraph(q.getQualifiedName()))
            output.append(DBParagraph("--------------------------REDEFINITION ERROR: Service Implementation Property has no redefinition and no Stereotype--------------------------"))  
            for p in insPropT3:
                gl.log("This element is not stereotyped, nor does it have a redefinition"+p.getQualifiedName())
                output.append(DBParagraph(p.getQualifiedName()))
            
                
            
    #        for j in mappingReqState:
    #            #gl.log("The system shall provide a "+mappingReqState[j].getName()+"  Timeline, that represents the  "+j.getName()+"Variable Type.")
    #            output.append(DBParagraph("The system shall provide a "+mappingReqState[j].getName()+"  Timeline, that represents the  "+j.getName()+"Variable Type."))
            output.append(DBParagraph("--------------------------Summary of Elements with Fix ME! Notation--------------------------"))
    #        gl.log("The total number of fix me elements:===>"+str(count))
            output.append(DBParagraph("The total number of fix me elements:=====> "+ str(count)))
            for j in Fixes:
                gl.log("The name of the element with Fix Me!:========>"+j.getName())         
                output.append(DBParagraph("The name of the element with Fix Me!:=====> "+ j.getQualifiedName()))
Exemplo n.º 2
0
from gov.nasa.jpl.mbee.lib import Utils
from gov.nasa.jpl.mgss.mbee.docgen.docbook import DBParagraph

scriptOutput = [DBParagraph("Hello Wrold")]
Exemplo n.º 3
0
from gov.nasa.jpl.mgss.mbee.docgen.docbook import DBParagraph
from gov.nasa.jpl.mgss.mbee.docgen.validation import ValidationRule
from gov.nasa.jpl.mgss.mbee.docgen.validation import ValidationSuite
from gov.nasa.jpl.mgss.mbee.docgen.validation import ViolationSeverity
from com.nomagic.uml2.ext.magicdraw.classes.mdkernel import *

targets = scriptInput['DocGenTargets']
# make a validation suite, give it a name
vs = ValidationSuite("TestSuite")
vs.setShowSummary(True)
vs.setShowDetail(True)
# each validation suite can have many rules, make one with name, description,
# and severity
vr = ValidationRule("Rule 1", "Stuff with names", ViolationSeverity.WARNING)
vr2 = ValidationRule("Rule 2", "Stuff that's Packages", ViolationSeverity.ERROR)
vs.addValidationRule(vr)
vs.addValidationRule(vr2)
# each rule can have many violations, give it the element and maybe some comment
for e in targets:
    for t in e.getOwnedElement():
        if isinstance(t, NamedElement) and t.getName() != "":
            vr.addViolation(t, "Has Name")
        if isinstance(t, Package):
            vr2.addViolation(t, "Is Package")
        
scriptOutput = {}
scriptOutput["DocGenValidationOutput"] = [vs]
scriptOutput["DocGenOutput"] = [DBParagraph("'Regular' output shows up first.")]
Exemplo n.º 4
0
    ###declare rules
    unused = ValidationRule(
        "Unused Stereotypes",
        "A stereotype is not applied in the model and can be deprecated",
        ViolationSeverity.ERROR)
    profvs.addValidationRule(unused)
    ###collect errors
    gl.log(str(depSter))
    for d in depSter:
        gl.log(str(d))
        unused.addViolation(d, "")

scriptOutput = {"DocGenValidationOutput": [profvs]}
if len(scriptInput['reportKind']) > 0:
    if scriptInput['reportKind'][0].getName() == 'log':
        profvs.setShowDetail(True)
        profvs.setShowSummary(False)
    else:
        profvs.setShowSummary(True)
        profvs.setShowDetail(False)
else:
    profvs.setShowSummary(True)
    profvs.setShowDetail(False)

###Collect Fix Onlys
fixOutput = []
for f in si:
    if si[f] == 'fix': fixOutput.append(DBParagraph(f))
gl.log('[FINISHED]')
scriptOutput["DocGenOutput"] = [DBParagraph("Profile Validation ")]
Exemplo n.º 5
0
from gov.nasa.jpl.mgss.mbee.docgen.docbook import DBParagraph
from gov.nasa.jpl.mgss.mbee.docgen.docbook import DBTable
from gov.nasa.jpl.mgss.mbee.docgen.docbook import DBText

output = []
output.append(DBParagraph("Inside Jython script! targets are:"))

for t in scriptInput['DocGenTargets']:
    output.append(DBParagraph(t.getName()))

sproperty = scriptInput['property'][
    0]  #stereotype properties are passed as lists
output.append(DBParagraph("A property on the userscript: " + sproperty))
output.append(
    DBParagraph("Magicdraw Installation Dir: " +
                scriptInput['md_install_dir']))
output.append(
    DBParagraph("ForViewEditor: " +
                str(scriptInput['ForViewEditor'])))  #boolean
output.append(
    DBParagraph("DocGen Output Dir: " + scriptInput['docgen_output_dir']))

output.append(DBParagraph("Table example"))

table = DBTable()
table.setBody([[DBText("hello"), DBText("World")],
               [DBText("blah"), DBText("blah")]])
table.setHeaders([[DBText("col1"), DBText("col2")]])
table.setTitle("Table from User Script")

output.append(table)
Exemplo n.º 6
0
output = []

thisProject = Application.getInstance().getProject()

INSPIREReqS = StereotypesHelper.getStereotype(thisProject, "INSPIRE.Requirement")

for t in targets:

    messaging.DBG(t.getName())
    
    idSlot = StereotypesHelper.getSlot(t, INSPIREReqS, "Id", False)
    coreText = ''
    for myVal in idSlot.getValue():
        coreText = myVal.getValue()

    output.append(DBParagraph(coreText + ' ' + t.getName()))

    textSlot = StereotypesHelper.getSlot(t, INSPIREReqS, "Text", False)
    coreText = ''
    for myVal in textSlot.getValue():
        coreText = myVal.getValue()
        
    output.append(DBParagraph(coreText))

    textSlot = StereotypesHelper.getSlot(t, INSPIREReqS, "Rationale", False)
    coreText = ''
    for myVal in textSlot.getValue():
        coreText = myVal.getValue()

    output.append(DBParagraph("<emphasis> Rationale: " + coreText + "</emphasis>"))
    output.append(DBParagraph(''))
Exemplo n.º 7
0
proj = Application.getInstance().getProject()
targets = scriptInput['DocGenTargets']

model = []                          #this is for the editable table body
headers = ['Document', 'Doc ID']    #this is for the editable table header
editable = [True, True]             #this is whether the table cells are editable
prop = [PropertyEnum.NAME, PropertyEnum.VALUE]       #this is what should be edited for each cell
stereotype = StereotypesHelper.getStereotype(proj, "Product", "Document Profile") #this is needed to get the slots

for t in targets:
    for doc in t.getOwnedElement():
        if StereotypesHelper.hasStereotype(doc, stereotype):
            #in this case, we want to edit the name and the JPL Document ID slot (stereotype tag) value
            #editing values can also apply to property default values - substitute the property element in
            model.append([doc, StereotypesHelper.getSlot(doc, stereotype, "JPL Document ID", False, False)])
    
# the None arguments can be replace with 2d lists if you want to specify 'editable' and 'prop' for each cell
table = EditableTable("Documents and Their ID", model, headers, None, None, None)
table.setEditableCol(editable)  #specify editability by column
table.setWhatToShowCol(prop)    #specify what property to edit by column
table.prepareTable()

# if you have a simple table that should render the same in docgen as the popup table, 
# use this, the second argument is whether to add line numbers at the left
docgenTable = Utils.getDBTableFromEditableTable(table, False)

scriptOutput = {}
scriptOutput["EditableTable"] = table          #this is for the editable table from gui
scriptOutput["DocGenOutput"] = [DBParagraph("Result:"), docgenTable] #regular output