@Operation(contextual = true, kind = Operation.Kind.HELPER) public static void addXsiSchemaLocation(DocumentRoot result,String key,String value) { EStringToStringMapEntryImpl metadataLocation=(EStringToStringMapEntryImpl) ((EcoreFactoryImpl)EcoreFactory.eINSTANCE).createEStringToStringMapEntry(); metadataLocation.setKey(key); metadataLocation.setValue(value); result.getXSISchemaLocation().add(metadataLocation); }
/** * convert the value of any EAttribute of an EObject to a string * @param att * @param attValue * @return */ private String stringValue(EAttribute att, Object attValue) { String val = ""; EDataType type = att.getEAttributeType(); String typeName = type.getName(); EcoreFactoryImpl fac = new EcoreFactoryImpl(); if (typeName.equals("EInt")) val = fac.convertEIntToString(type, attValue); else if (typeName.equals("EString")) val = fac.convertEStringToString(type, attValue); // ... etc; add more as needed else {System.out.println("Cannot yet handle Ecore type " + typeName);} return val; }
private final static List<BasicEMap.Entry<String, String>> getXmlNsList() { List<EPackage> packages = new ArrayList<EPackage>(); // resource packages packages.add(Db2ResourcePackage.eINSTANCE); packages.add(DirectoryResourcePackage.eINSTANCE); packages.add(FileResourcePackage.eINSTANCE); packages.add(InformixResourcePackage.eINSTANCE); packages.add(MqResourcePackage.eINSTANCE); packages.add(OracleResourcePackage.eINSTANCE); packages.add(QueryResourcePackage.eINSTANCE); packages.add(ReferenceResourcePackage.eINSTANCE); packages.add(ShadowDirectResourcePackage.eINSTANCE); packages.add(SoapIOResourcePackage.eINSTANCE); packages.add(SybaseResourcePackage.eINSTANCE); packages.add(TeradataResourcePackage.eINSTANCE); packages.add(UdbResourcePackage.eINSTANCE); packages.add(NullResourcePackage.eINSTANCE); packages.add(TransactionResourcePackage.eINSTANCE); packages.add(SemaphoreResourcePackage.eINSTANCE); packages.add(LdapResourcePackage.eINSTANCE); packages.add(LdapQueryResourcePackage.eINSTANCE); packages.add(SqliteResourcePackage.eINSTANCE); packages.add(MssqlResourcePackage.eINSTANCE); // global packages packages.add(ValuesPackage.eINSTANCE); packages.add(TypesPackage.eINSTANCE); packages.add(ListenersPackage.eINSTANCE); packages.add(RepetitionPackage.eINSTANCE); packages.add(SaturnWebPackage.eINSTANCE); packages.add(SaturnReportPackage.eINSTANCE); // module packages packages.add(CpsModulePackage.eINSTANCE); packages.add(DatacompareModulePackage.eINSTANCE); packages.add(DsConvertModulePackage.eINSTANCE); packages.add(DsValidatorModulePackage.eINSTANCE); packages.add(EnvValidatorModulePackage.eINSTANCE); packages.add(ExtractDDLModulePackage.eINSTANCE); packages.add(MailModulePackage.eINSTANCE); packages.add(MqModulePackage.eINSTANCE); packages.add(ProcedureCallModulePackage.eINSTANCE); packages.add(PsManagerModulePackage.eINSTANCE); packages.add(RuncmdsModulePackage.eINSTANCE); packages.add(SingularityModulePackage.eINSTANCE); packages.add(SoapIOModulePackage.eINSTANCE); packages.add(SqlModulePackage.eINSTANCE); packages.add(Xml2csvModulePackage.eINSTANCE); packages.add(XmlDiffModulePackage.eINSTANCE); packages.add(XmlGenModulePackage.eINSTANCE); packages.add(XmlManipModulePackage.eINSTANCE); packages.add(XmlValidatorModulePackage.eINSTANCE); packages.add(CometModulePackage.eINSTANCE); packages.add(XSplitModulePackage.eINSTANCE); packages.add(ReferenceModulePackage.eINSTANCE); packages.add(DocumentumModulePackage.eINSTANCE); List<BasicEMap.Entry<String, String>> xmlNsList = new ArrayList<BasicEMap.Entry<String, String>>(); for (EPackage ePackage : packages) { ((EcoreFactoryImpl) EcoreFactory.eINSTANCE).createEStringToStringMapEntry(); BasicEMap.Entry<String, String> newEntry = (BasicEMap.Entry<String, String>) EcoreUtil .create((EClass) SaturnPackage.eINSTANCE.getDocumentRoot_XMLNSPrefixMap().getEType()); // new EStringToStringMapEntryImpl(); // //((EcoreFactoryImpl)EcoreFactory.eINSTANCE).createEStringToStringMapEntry(); xmlNsList.add(newEntry); newEntry.setKey(ePackage.getNsPrefix()); newEntry.setValue(ePackage.getNsURI()); } return xmlNsList; }