package org.tianocore.frameworkwizard.module.Identifications;\r
\r
\r
+import java.io.IOException;\r
+\r
+import org.apache.xmlbeans.XmlException;\r
+import org.tianocore.LibraryUsage;\r
+import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
+import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
+import org.tianocore.frameworkwizard.common.DataType;\r
+import org.tianocore.frameworkwizard.common.OpenFile;\r
import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
\r
\r
private PackageIdentification packageId;\r
\r
+ private String moduleType;\r
+ \r
+ private boolean isLibrary;\r
+ \r
public ModuleIdentification(String name, String guid, String version, String path) {\r
super(name, guid, version, path);\r
+ setModuleType();\r
}\r
\r
- public ModuleIdentification(Identification id) {\r
+ public ModuleIdentification(String name, String guid, String version, String path, boolean library) {\r
+ super(name, guid, version, path);\r
+ this.isLibrary = library;\r
+ }\r
+ \r
+ public ModuleIdentification(Identification id, boolean library) {\r
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
+ this.isLibrary = library;\r
}\r
\r
public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId){\r
super(name, guid, version, path);\r
this.packageId = packageId;\r
+ setModuleType();\r
+ }\r
+ \r
+ public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId, String type){\r
+ super(name, guid, version, path);\r
+ this.packageId = packageId;\r
+ this.moduleType = type;\r
}\r
\r
public ModuleIdentification(Identification id, PackageIdentification packageId) {\r
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
this.packageId = packageId;\r
+ setModuleType();\r
}\r
\r
-// public boolean equals(Object obj) {\r
-// if (obj instanceof Identification) {\r
-// Identification id = (Identification)obj;\r
-// if ( this.getName().equalsIgnoreCase(id.getName())) {\r
-// return true;\r
-// }\r
-// // and package is the same one\r
-// return false;\r
-// }\r
-// else {\r
-// return super.equals(obj);\r
-// }\r
-// }\r
+ public ModuleIdentification(Identification id, PackageIdentification packageId, boolean library) {\r
+ super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
+ this.packageId = packageId;\r
+ this.isLibrary = library;\r
+ }\r
+ \r
+ public ModuleIdentification(Identification id, PackageIdentification packageId, String type) {\r
+ super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
+ this.packageId = packageId;\r
+ this.moduleType = type;\r
+ }\r
\r
public String toString(){\r
return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;\r
public void setPackageId(PackageIdentification packageId) {\r
this.packageId = packageId;\r
}\r
+\r
+ public String getModuleType() {\r
+ return moduleType;\r
+ }\r
+\r
+ public void setModuleType(String moduleType) {\r
+ this.moduleType = moduleType;\r
+ }\r
+ \r
+ private void setModuleType() {\r
+ ModuleSurfaceArea msa = null;\r
+ try {\r
+ msa = OpenFile.openMsaFile(this.getPath());\r
+ } catch (IOException e) {\r
+ // TODO Auto-generated catch block\r
+ \r
+ } catch (XmlException e) {\r
+ // TODO Auto-generated catch block\r
+ \r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ \r
+ }\r
+ setModuleType(DataType.MODULE_TYPE_MODULE);\r
+ setLibrary(false);\r
+ if (msa != null) {\r
+ LibraryClassDefinitions lib = msa.getLibraryClassDefinitions();\r
+ if (lib != null) {\r
+ for (int index = 0; index < lib.getLibraryClassList().size(); index++) {\r
+ if (lib.getLibraryClassList().get(index).getUsage().equals(LibraryUsage.ALWAYS_PRODUCED)) {\r
+ setModuleType(DataType.MODULE_TYPE_LIBRARY);\r
+ setLibrary(true);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ public boolean isLibrary() {\r
+ return isLibrary;\r
+ }\r
+\r
+ public void setLibrary(boolean isLibrary) {\r
+ this.isLibrary = isLibrary;\r
+ }\r
}\r