From c3cd956a7e80cbc4aa50cec5b7a6d19649a5e48b Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Tue, 3 Dec 2019 15:36:58 +0100 Subject: [PATCH] key pour les ASSD --- Efi2Xsd/AccasXsd.py | 51 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index 6f2dec88..90f9e4d7 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -36,6 +36,16 @@ class X_definition: self.nomDuCodeDumpe = obj.nomDuCodeDumpe self.code=obj.code + def getXPath(self): + obj=self + textePath=self.nom + while ( hasattr(obj,'pere') ): + obj=obj.pere + if isinstance(obj, X_BLOC) : continue + textePath= obj.nom + '/' + textePath + textePath='./'+ self.code + ":" + textePath + return textePath + #def genealogie(self,n): # texte=self.nom # obj=self @@ -159,14 +169,18 @@ class X_FACT (X_definitionComposee): class X_OPER (X_definitionComposee): # --------------------------------- def dumpXsd(self): -# X_definitionComposee.dumpXsd(self, inExtension) X_definitionComposee.dumpXsd(self) self.texteComplexe += finTypeCompoSeq self.texteComplexe += operAttributeName self.texteComplexe += attributeTypeForASSD self.texteComplexe += attributeTypeUtilisateurName.format(self.sd_prod.__name__) self.texteComplexe += finTypeCompo - + cata = CONTEXT.getCurrentCata() + if self.sd_prod.__name__ not in list(cata.dictTypesASSDorUserASSDCrees) : + cata.dictTypesASSDorUserASSDCrees[self.sd_prod.__name__]=[self,] + else : + cata.dictTypesASSDorUserASSDCrees[self.sd_prod.__name__].append(self) + # ---------------------------------- class X_PROC (X_definitionComposee): @@ -294,7 +308,14 @@ class X_SIMP (X_definition): else : typeATraduire=self.type[0] if not (typeATraduire in list(dictNomsDesTypes.keys())) : - if (isinstance(typeATraduire, Accas.ASSD) or issubclass(typeATraduire, Accas.ASSD)) : return 'xs:string' + if (isinstance(typeATraduire, Accas.ASSD) or issubclass(typeATraduire, Accas.ASSD)) : + cata = CONTEXT.getCurrentCata() + cata.dictTypesASSDorUserASSDUtilises[typeATraduire]=self + if typeATraduire not in list(cata.dictTypesASSDorUserASSDCrees) : + cata.dictTypesASSDorUserASSDUtilises[typeATraduire]=[self,] + else : + cata.dictTypesASSDorUserASSDUtilises[typeATraduire].append(self,) + return 'xs:string' else : return ('YYYYY') return dictNomsDesTypes[typeATraduire] @@ -368,6 +389,28 @@ class X_JDC_CATA : if self.texteTypeAbstrait != "" : self.texteXSD += self.texteTypeAbstrait self.texteXSD += self.texteCata self.texteXSD += self.texteElt + + texteKeyRef = "" + for clef in self.dictTypesASSDorUserASSDCrees: + texteDesFields="" + for unOper in self.dictTypesASSDorUserASSDCrees[clef]: + texteDesFields+=texteFieldUnitaire.format(self.code, unOper.nom) + texteDesFields=texteDesFields[0:-2] + if texteDesFields != "" : + texteKeyRef += producingASSDkeyRefDeclaration.format( clef ,texteDesFields) + + + for clef in self.dictTypesASSDorUserASSDUtilises: + for unSimp in self.dictTypesASSDorUserASSDUtilises[clef]: + # il faut la genealogie + print (unSimp.getXPath()) + texteKeyRef += UsingASSDkeyRefDeclaration.format(unSimp.nom, unSimp.type[0].__name__,self.code, unSimp.type[0].__name__,unSimp.getXPath() ) + + if texteKeyRef != '' : + self.texteXSD = self.texteXSD[0:-3]+'>\n' + self.texteXSD += texteKeyRef + self.texteXSD += fermeEltCata + self.texteXSD += texteFin #if not PourTraduction : print (self.texteXSD) @@ -443,4 +486,4 @@ class X_JDC_CATA : self.texteSimple += c.texteSimple self.texteComplexe += c.texteComplexe c.texteElt=eltCompoDsSequenceInExtension.format(c.nom,self.code,c.nomDuTypePyxb) - self.texteCata += c.texteElt + self.texteCata += c.texteElt -- 2.39.2