+ public void addFarToDb(List<String> packageList, List<String> platformList, FarHeader far) {\r
+ FrameworkDatabase fdb = openFrameworkDb();\r
+ \r
+ for (int i = 0; i < packageList.size(); i++) {\r
+ DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();\r
+ item.setFarGuid(far.getGuidValue());\r
+ item.setStringValue(packageList.get(i));\r
+ fdb.getPackageList().getFilenameList().add(item);\r
+ }\r
+ \r
+ for (int i = 0; i < platformList.size(); i++) {\r
+ DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();\r
+ item.setFarGuid(far.getGuidValue());\r
+ item.setStringValue(platformList.get(i));\r
+ fdb.getPlatformList().getFilenameList().add(item);\r
+ }\r
+ \r
+ DbPathAndFilename farItem = DbPathAndFilename.Factory.newInstance();\r
+ farItem.setFarGuid(far.getGuidValue());\r
+ farItem.setStringValue(far.getFarName());\r
+ fdb.getFarList().getFilenameList().add(farItem);\r
+ \r
+ String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();\r
+ strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);\r
+ \r
+ try {\r
+ SaveFile.saveDbFile(strFrameworkDbFilePath, fdb);\r
+ }\r
+ catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ \r
+ public void removeFarFromDb(FarIdentification far) {\r
+ FrameworkDatabase fdb = openFrameworkDb();\r
+ //\r
+ // Remove Packages\r
+ //\r
+ XmlCursor cursor = fdb.getPackageList().newCursor();\r
+ cursor.toFirstChild();\r
+ do {\r
+ DbPathAndFilename item = (DbPathAndFilename)cursor.getObject();\r
+ \r
+ if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+ cursor.removeXml();\r
+ }\r
+ } while (cursor.toNextSibling());\r
+ cursor.dispose();\r
+ \r
+ //\r
+ // Remove Platforms\r
+ //\r
+ cursor = fdb.getPlatformList().newCursor();\r
+ cursor.toFirstChild();\r
+ do {\r
+ DbPathAndFilename item = (DbPathAndFilename)cursor.getObject();\r
+ if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+ cursor.removeXml();\r
+ }\r
+ } while (cursor.toNextSibling());\r
+ \r
+ //\r
+ // Remove Far\r
+ //\r
+ cursor = fdb.getFarList().newCursor();\r
+ cursor.toFirstChild();\r
+ do {\r
+ DbPathAndFilename item = (DbPathAndFilename)cursor.getObject();\r
+ if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+ cursor.removeXml();\r
+ }\r
+ } while (cursor.toNextSibling());\r
+ cursor.dispose();\r
+ \r
+ String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();\r
+ strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);\r
+ try {\r
+ SaveFile.saveDbFile(strFrameworkDbFilePath, fdb);\r
+ }\r
+ catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ public String getPackageFarGuid(PackageIdentification packageId) {\r
+ openFrameworkDb();\r
+ \r
+ for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) {\r
+ DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index);\r
+ String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR\r
+ + item.getStringValue();\r
+ File tempFile = new File(path);\r
+ if (tempFile.getPath().equalsIgnoreCase(packageId.getSpdFile().getPath())) {\r
+ return fdb.getPackageList().getFilenameArray(index).getFarGuid();\r
+ }\r
+ }\r
+ \r
+ return null;\r
+ }\r
+ \r
+ public String getPlatformFarGuid(PlatformIdentification platformId) {\r
+ openFrameworkDb();\r
+ \r
+ for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) {\r
+ DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index);\r
+ String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR\r
+ + item.getStringValue();\r
+ File tempFile = new File(path);\r
+ if (tempFile.getPath().equalsIgnoreCase(platformId.getFpdFile().getPath())) {\r
+ return fdb.getPlatformList().getFilenameArray(index).getFarGuid();\r
+ }\r
+ }\r
+ \r
+ return null;\r
+ }\r
+ \r
+ public String getModuleFarGuid(ModuleIdentification moduleId) {\r
+ PackageIdentification packageId = getPackageIdByModuleId(moduleId);\r
+ if (packageId != null) {\r
+ return getPackageFarGuid(packageId);\r
+ }\r
+ else {\r
+ return null;\r
+ }\r
+ }\r