def createArchimateConcepts(fileArchimate, fileConceptsArch): logger.info(u"Using : %s" % fileArchimate) concepts = Concepts(fileArchimateModel, u"Archimate") al = ArchiLib(fileArchimate) al.logTypeCounts() # # Create Concepts from Archimate # al.folderConcepts(concepts) Concepts.saveConcepts(concepts, fileConceptsArch) logger.info(u"Saved concepts to : %s" % fileConceptsArch)
def test_ArchiCounts(cleandir, fileArchimate): assert (os.path.isfile(fileArchimate) is True) al = ArchiLib(fileArchimateTest) lc = al.logTypeCounts() assert (len(lc) > 0)
def ImportCSVIntoArchi(fileArchimate, folder, subfolder, fileMetaEntity): start_time = ArchiLib.startTimer() logger.info(u"Using : %s" % fileArchimate) al = ArchiLib(fileArchimate) _ = al.logTypeCounts(ListOnly=True) al.insertNColumns(folder, subfolder, fileMetaEntity, CaseFix=False) al.outputXMLtoFile() relations = len(al.dictRel) nodes = len(al.dictND) logger.info(u"----------------------------------------------------------------------------------------") logger.info(u"Encountered %d errors and added %d Nodes and %d relations" % (len(al.listErrors), nodes, relations)) ArchiLib.stopTimer(start_time)
def organizeFolders(fileArchimate): logger.info(u"Using : %s" % fileArchimate) al = ArchiLib(fileArchimate) for folder in entityFolders: pass sl = al.logTypeCounts() nl = [(x[10:], y) for x, y in sl] n = 0 for k, v in al.dictNodes.items(): logger.debug(u"%s" % v) n += 1 try: af = v[ARCHI_TYPE][10:] except KeyError, msg: continue if af in entityFolders: logger.debug(u"%d - %s - %s : %s" % (n, v[NAME], af, entityFolders[af])) Add(af) else: logger.info(u"%d Missing - %s" % (n, af)) if False: # Create Subfolder folder = u"Implementation & Migration" subfolder = u"Dependancy Analysis - %s" % time.strftime(u"%Y%d%m_%H%M%S") attrib = dict() attrib[u"id"] = al.getID() attrib[u"name"] = subfolder al.insertNode(u"folder", folder, attrib)
def test_CreateArchimateConcepts(cleandir, fileArchimate): assert (os.path.isfile(fileArchimate) is True) logger.info(u"Using : %s" % fileArchimate) concepts = Concepts(fileArchimate, u"Archimate") al = ArchiLib(fileArchimate) lc = al.logTypeCounts() assert (len(lc) > 0) # # Create Concepts from Archimate # al.folderConcepts(concepts) Concepts.saveConcepts(concepts, fileConceptsArch) logger.info(u"Saved concepts to : %s" % fileConceptsArch) assert (os.path.isfile(fileConceptsArch) is True)
def cleanArchimateRelationships(fileArchimate): al = ArchiLib(fileArchimate) al.logTypeCounts() n = 0 countInvalid = 0 for x in al.tree.getroot().iter(): n += 1 try: if ARCHI_TYPE in x.attrib and x.attrib[ARCHI_TYPE] in relations.values(): sid = x.get(u"source") srcElm = al.findElementByID(sid)[0] tid = x.get(u"target") tgtElm = al.findElementByID(tid)[0] if srcElm is None or tgtElm is None: logger.warn(u"Invalid Relationship : %s[%s]" % (x.get(u"id"), x.get(ARCHI_TYPE))) else: logger.debug(u"Valid Relationship : %s[%s]" % (x.get(u"id"), x.get(ARCHI_TYPE))) # <child xsi:type="archimate:DiagramObject" id="2be1001e" textAlignment="2" archimateElement="eedbdc28"> # <bounds x="692" y="624" width="120" height="55"/> # <sourceConnection xsi:type="archimate:Connection" id="c90d2077" source="2be1001e" target="aff3d6b3" relationship="56057f65"/> # <sourceConnection xsi:type="archimate:Connection" id="d5cac998" source="2be1001e" target="dfa5c47b" relationship="99bc54ab"/> # <sourceConnection xsi:type="archimate:Connection" id="3174a55b" source="2be1001e" target="0308d4c3" relationship="67e21821"/> # </child> elif ARCHI_TYPE in x.attrib and x.get(ARCHI_TYPE) == DIAGRAM_OBJECT: ae = x.get(u"archimateElement") aeDO = al.findDiagramObject(ae)[0].attrib aeid = aeDO[u"archimateElement"] aeElm = al.findElementByID(aeid)[0] logger.debug(u"%s[%s] " % (aeElm.get(u"name"), aeElm.get(ARCHI_TYPE))) elif ARCHI_TYPE in x.attrib and x.tag == u"sourceConnection": src = x.get(u"source") srcDO = al.findDiagramObject(src)[0].attrib sid = srcDO[u"archimateElement"] srcElm = al.findElementByID(sid)[0] trc = x.get(u"target") tgtDO = al.findDiagramObject(trc)[0].attrib tid = tgtDO[u"archimateElement"] tgtElm = al.findElementByID(tid)[0] rrc = x.get(u"relationship") relElm = al.findElementByID(rrc)[0] rid = relElm.get(ARCHI_TYPE)[10:] logger.debug(u" S - %s -> [%s] -> %s" % ((srcElm.get(u"name"), rid, tgtElm.get(u"name")))) else: if u"name" in x.attrib and x.attrib.has_key(ARCHI_TYPE): logger.info(u"Skipping - %s[%s] - %s" % (x.get(ARCHI_TYPE)[10:], x.get(u"id"), x.get(u"name")[:20])) else: logger.debug(u"Skipping - %s[%s]" % (x.tag, x.get(u"id"))) except: countInvalid += 1 logger.error(u"Error - %s[%s]" % (x.tag, x.get(u"id"))) logger.info(u"Validated %d Elements" % n) al.logTypeCounts()
#!/usr/bin/python # # Archimate Counts # __author__ = u'morrj140' __VERSION__ = u'0.3' import os from Logger import * logger = setupLogging(__name__) logger.setLevel(INFO) from al_lib.ArchiLib import ArchiLib if __name__ == u"__main__": pathModel = u"/Users/morrj140/Documents/SolutionEngineering/Archimate Models" fileArchimateXML = u"DVC v3.17.archimate" fileArchimate = pathModel + os.sep + fileArchimateXML al = ArchiLib(fileArchimate) al.logTypeCounts()