}\r
ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();\r
while (li.hasNext()) {\r
- ModuleSADocument.ModuleSA msa = li.next();\r
- if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) {\r
+ ModuleSADocument.ModuleSA moduleSa = li.next();\r
+ if (moduleSa.getPcdBuildDefinition() == null || moduleSa.getPcdBuildDefinition().getPcdDataList() == null) {\r
continue;\r
}\r
- String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() +\r
- " " + msa.getPackageGuid() + " " + msa.getPackageVersion() + " " + listToString(msa.getSupArchList());\r
- List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = msa.getPcdBuildDefinition().getPcdDataList();\r
+ String ModuleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() +\r
+ " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r
+ List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = moduleSa.getPcdBuildDefinition().getPcdDataList();\r
ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();\r
while (lpi.hasNext()) {\r
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();\r
}\r
ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
while(li.hasNext()) {\r
- ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r
- if (msa.getModuleGuid().equalsIgnoreCase(s[0]) && msa.getPackageGuid().equalsIgnoreCase(s[2])) {\r
- if (msa.getModuleVersion() != null) {\r
- if (!msa.getModuleVersion().equals(s[1])) {\r
+ ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+ if (moduleSa.getModuleGuid().equalsIgnoreCase(s[0]) && moduleSa.getPackageGuid().equalsIgnoreCase(s[2])) {\r
+ if (moduleSa.getModuleVersion() != null) {\r
+ if (!moduleSa.getModuleVersion().equals(s[1])) {\r
continue;\r
}\r
}\r
- if (msa.getPackageVersion() != null) {\r
- if (!msa.getPackageVersion().equals(s[3])) {\r
+ if (moduleSa.getPackageVersion() != null) {\r
+ if (!moduleSa.getPackageVersion().equals(s[3])) {\r
continue;\r
}\r
}\r
//ToDo add arch check for s[4]\r
- if (msa.getSupArchList() != null) {\r
- if (!listToString(msa.getSupArchList()).equals(s[4])) {\r
+ if (moduleSa.getSupArchList() != null) {\r
+ if (!listToString(moduleSa.getSupArchList()).equals(s[4])) {\r
continue;\r
}\r
}\r
- return msa;\r
+ return moduleSa;\r
}\r
}\r
return null;\r
}\r
\r
private ModuleSADocument.ModuleSA getModuleSA(int i) {\r
- ModuleSADocument.ModuleSA msa = null;\r
+ ModuleSADocument.ModuleSA moduleSa = null;\r
if (fpdRoot.getFrameworkModules() == null) {\r
return null;\r
}\r
for (int j = 0; j < i; ++j) {\r
cursor.toNextSibling();\r
}\r
- msa = (ModuleSADocument.ModuleSA)cursor.getObject();\r
+ moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r
}\r
cursor.dispose();\r
- return msa;\r
+ return moduleSa;\r
}\r
\r
public void removeModuleSA(int i) {\r
cursor.dispose();\r
}\r
\r
+ public boolean adjustPcd (int seqModuleSa) throws Exception {\r
+ boolean dataModified = false;\r
+ ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r
+ int pcdCount = getPcdDataCount(seqModuleSa);\r
+ String[][] saaModuleSaPcd = new String[pcdCount][7];\r
+ getPcdData(seqModuleSa, saaModuleSaPcd);\r
+ String mg = moduleSa.getModuleGuid();\r
+ String mv = moduleSa.getModuleVersion();\r
+ String pg = moduleSa.getPackageGuid();\r
+ String pv = moduleSa.getPackageVersion();\r
+ String arch = listToString(moduleSa.getSupArchList());\r
+ //\r
+ // delete pcd in ModuleSA but not in MSA files any longer.\r
+ //\r
+ String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r
+ int libCount = getLibraryInstancesCount(moduleKey);\r
+ String[][] saaLib = new String[libCount][5];\r
+ getLibraryInstances(moduleKey, saaLib);\r
+ ModuleIdentification mi = GlobalData.getModuleId(moduleKey);\r
+ Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r
+ vMi.add(mi);\r
+ try {\r
+ nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r
+ if (GlobalData.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], mi)){\r
+ continue;\r
+ }\r
+ for (int j = 0; j < saaLib.length; ++j) {\r
+ String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r
+ ModuleIdentification libMi = GlobalData.getModuleId(libKey);\r
+ vMi.add(libMi);\r
+ if (GlobalData.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], libMi)) {\r
+ continue nextPcd;\r
+ }\r
+ }\r
+ removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r
+ dataModified = true;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ \r
+ }\r
+ //\r
+ // add new Pcd from MSA file to ModuleSA.\r
+ //\r
+ try {\r
+ \r
+ for (int i = 0; i < vMi.size(); ++i) {\r
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) GlobalData\r
+ .getModuleXmlObject(vMi\r
+ .get(i));\r
+ if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {\r
+ continue;\r
+ }\r
+ ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator();\r
+ msaPcdIter:while (li.hasNext()) {\r
+ PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r
+ ArrayList<String> al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName());\r
+ if (al != null) {\r
+ for (int j = 0; j < al.size(); ++j) {\r
+ if (al.get(j).contains(moduleKey)) {\r
+ continue msaPcdIter;\r
+ }\r
+ }\r
+ }\r
+ \r
+ Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
+ m.put("ModuleSurfaceArea", msa);\r
+ SurfaceAreaQuery.setDoc(m);\r
+ PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);\r
+ PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
+ if (spdPcd == null) {\r
+ //\r
+ // ToDo Error \r
+ //\r
+ throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r
+ + mi.getName());\r
+ }\r
+ //\r
+ // AddItem to ModuleSA PcdBuildDefinitions\r
+ //\r
+ String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue()\r
+ : msaPcd.getDefaultValue();\r
+\r
+ genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(),\r
+ msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa);\r
+ dataModified = true;\r
+ }\r
+\r
+ }\r
+ }\r
+ catch (Exception e){\r
+ throw e;\r
+ }\r
+ \r
+ return dataModified;\r
+ }\r
+ \r
private void maintainDynPcdMap(String pcdKey, String moduleInfo) {\r
\r
ArrayList<String> al = dynPcdMap.get(pcdKey);\r
//\r
// key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r
//\r
- public int getPcdDataCount(int i){\r
+ public int getPcdDataCount (int i){\r
ModuleSADocument.ModuleSA msa = getModuleSA(i);\r
\r
if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r
\r
}\r
\r
- public void getPcdData(int i, String[][] saa) {\r
+ public void getPcdData (int i, String[][] saa) {\r
ModuleSADocument.ModuleSA msa = getModuleSA(i);\r
\r
if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r
}\r
}\r
\r
- public void updatePcdData(String key, String cName, String tsGuid, String itemType, String maxSize, String value){\r
- ModuleSADocument.ModuleSA msa = getModuleSA(key);\r
- if (msa == null || msa.getPcdBuildDefinition() == null){\r
+ public void removePcdData (int seqModuleSa, String cName, String tsGuid) {\r
+ ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r
+ if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){\r
return;\r
}\r
\r
- XmlCursor cursor = msa.getPcdBuildDefinition().newCursor();\r
+ String mg = moduleSa.getModuleGuid();\r
+ String mv = moduleSa.getModuleVersion();\r
+ String pg = moduleSa.getPackageGuid();\r
+ String pv = moduleSa.getPackageVersion();\r
+ String arch = listToString(moduleSa.getSupArchList());\r
+ String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r
+ \r
+ XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor();\r
+ if (cursor.toFirstChild()){\r
+ \r
+ do {\r
+ PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r
+ if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r
+ maintainDynPcdMap(cName + " " + tsGuid, moduleKey);\r
+ if (getPcdDataCount(seqModuleSa) == 1) {\r
+ cursor.toParent();\r
+ }\r
+ cursor.removeXml();\r
+ break;\r
+ }\r
+ }\r
+ while(cursor.toNextSibling());\r
+ \r
+ }\r
+ cursor.dispose();\r
+ }\r
+ \r
+ public void updatePcdData (String key, String cName, String tsGuid, String itemType, String maxSize, String value){\r
+ ModuleSADocument.ModuleSA moduleSa = getModuleSA(key);\r
+ if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){\r
+ return;\r
+ }\r
+ \r
+ XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor();\r
if (cursor.toFirstChild()){\r
do {\r
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r
* @param sa Results: HelpText, Original item type.\r
* @return\r
*/\r
- public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String[] sa) throws Exception{\r
+ public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{\r
try {\r
\r
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);\r
if (!msaPcd.getCName().equals(cName)) {\r
continue;\r
}\r
+ if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {\r
+ continue;\r
+ }\r
PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
if (spdPcd == null) {\r
//\r
XmlCursor cursor = instance.newCursor();\r
try{\r
String comment = "Pkg: " + pn + " Mod: " + mn \r
- + " Path: " + GlobalData.getMsaFile(libMi).getPath();\r
+ + " Path: " + GlobalData.getMsaFile(libMi).getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
cursor.insertComment(comment);\r
}\r
catch (Exception e){\r
XmlCursor cursor = msa.newCursor();\r
try{\r
String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: "\r
- + GlobalData.getMsaFile(mi).getPath();\r
+ + GlobalData.getMsaFile(mi).getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
cursor.insertComment(comment);\r
}\r
catch(Exception e){\r
return null;\r
}\r
\r
- /**\r
- * Get the PcdToken array from module's surface area document. The array\r
- * should contains following data:\r
- * <p>\r
- * -------------------------------------------------------------------\r
- * </p>\r
- * <p>\r
- * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText\r
- * </p>\r
- * <p>\r
- * -------------------------------------------------------------------\r
- * </p>\r
- * <p>\r
- * Note: Until new schema applying, now we can only get CName, ItemType,\r
- * </p>\r
- * \r
- * @return 2-array table contains all information of PCD token retrieved\r
- * from MSA.\r
- */\r
- public static Object[][] etModulePCDTokenArray() {\r
- return null;\r
- // int index;\r
- // Object[][] result;\r
- // PCDs.PcdData[] pcds;\r
- // String[] xPath = new String[] { "/PcdData" };\r
- // XmlObject[] returns = get("PCDs", xPath);\r
- //\r
- // if ((returns == null) || (returns.length == 0)) {\r
- // return null;\r
- // }\r
- //\r
- // pcds = (PCDs.PcdData[]) returns;\r
- // result = new Object[pcds.length][6];\r
- // for (index = 0; index < pcds.length; index++) {\r
- // //\r
- // // Get CName\r
- // //\r
- // result[index][0] = pcds[index].getCName();\r
- // //\r
- // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,\r
- // // DYNAMIC, DYNAMIC_EX\r
- // //\r
- // if (pcds[index].getItemType() != null) {\r
- // result[index][1] = pcds[index].getItemType().toString();\r
- // } else {\r
- // result[index][1] = null;\r
- // }\r
- //\r
- // //\r
- // // BUGBUG: following field can *not* be got from current MSA until\r
- // // schema changed.\r
- // //\r
- // // result [index][2] = pcds[index].getTokenSpaceName();\r
- // result[index][2] = null;\r
- // result[index][3] = pcds[index].getDefaultValue();\r
- // // result [index][4] = pcds[index].getUsage ();\r
- // result[index][4] = null;\r
- // // result [index][5] = pcds[index].getHelpText ();\r
- // result[index][5] = null;\r
- // }\r
- // return result;\r
- }\r
+ \r
\r
/**\r
- * Retrieve MAS header\r
+ * Retrieve MSA header\r
* \r
* @return\r
* @return\r