Forum Post: Re: Apis Used While Importing Metadata For An Ecore File

  • Thread starter Thread starter sjigesh
  • Start date Start date
Status
Not open for further replies.
S

sjigesh

Guest
Hi All, I tried the below code for clearing and importing metadata but the problem that I am facing is after importing the metadata the size of ecore file is reduced to 1 KB .Originally the size was around 2.7MB Unable to figure out what is the issue. Can some one please help me out with this one public class TestJavaMetaData { public static void main(String[] args) { TestJavaMetaData TMTD = new TestJavaMetaData(); TMTD.ClearImportMetaData(); } public void ClearImportMetaData() { try { IJavaMetadataAPI JMD= new JavaMetadataAPIImpl(); URI modelURI=URI.createFileURI("C:\\..P.ecore"); JMD.loadResource(modelURI); ResourceSet resourceSet=new ResourceSetImpl(); Resource xmiResource=resourceSet.createResource(modelURI); JMD.reloadResource(xmiResource); JMD.clearCache(); TestMetaData TMDA = new TestMetaData(); List classNames =TMDA.getJarsList(); List JarNames= new ArrayList (); JarNames.add("file:C:\\Jars"); JMD.load(classNames,JarNames,null); JMD.saveResource(xmiResource); } catch(Exception e) { e.printStackTrace(); } } public List getJarsList() throws IOException { List classNames = new ArrayList (); ZipInputStream zip = new ZipInputStream(new FileInputStream("C:\\...P.jar")); for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { if (!entry.isDirectory() && entry.getName().endsWith(".class")) { // This ZipEntry represents a class. Now, what class does it represent? String className = entry.getName().replace('/', '.'); // including ".class" classNames.add(className.substring(0, className.length() - ".class".length())); } } return classNames; } }

Continue reading...
 
Status
Not open for further replies.
Back
Top