3 The file is used to init workspace and get basic information of workspace
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 package org
.tianocore
.frameworkwizard
.workspace
;
18 import java
.io
.IOException
;
19 import java
.util
.List
;
20 import java
.util
.Vector
;
22 import org
.apache
.xmlbeans
.XmlCursor
;
23 import org
.apache
.xmlbeans
.XmlException
;
24 import org
.tianocore
.DbPathAndFilename
;
25 import org
.tianocore
.IndustryStdIncludesDocument
.IndustryStdIncludes
;
26 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
27 import org
.tianocore
.MsaFilesDocument
.MsaFiles
;
28 import org
.tianocore
.PackageDependenciesDocument
.PackageDependencies
;
29 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
30 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
31 import org
.tianocore
.SourceFilesDocument
.SourceFiles
;
32 import org
.tianocore
.frameworkwizard
.common
.DataType
;
33 import org
.tianocore
.frameworkwizard
.common
.GlobalData
;
34 import org
.tianocore
.frameworkwizard
.common
.Log
;
35 import org
.tianocore
.frameworkwizard
.common
.OpenFile
;
36 import org
.tianocore
.frameworkwizard
.common
.SaveFile
;
37 import org
.tianocore
.frameworkwizard
.common
.Sort
;
38 import org
.tianocore
.frameworkwizard
.common
.Tools
;
39 import org
.tianocore
.frameworkwizard
.common
.Identifications
.Identification
;
40 import org
.tianocore
.frameworkwizard
.far
.FarHeader
;
41 import org
.tianocore
.frameworkwizard
.far
.FarIdentification
;
42 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
43 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdIdentification
;
44 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdVector
;
45 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
46 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
48 public class WorkspaceTools
{
50 public void addFarToDb(List
<String
> packageList
, List
<String
> platformList
, FarHeader far
) {
51 //FrameworkDatabase fdb = openFrameworkDb();
53 for (int i
= 0; i
< packageList
.size(); i
++) {
54 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
55 item
.setFarGuid(far
.getGuidValue());
56 item
.setStringValue(packageList
.get(i
));
57 GlobalData
.fdb
.getPackageList().getFilenameList().add(item
);
60 for (int i
= 0; i
< platformList
.size(); i
++) {
61 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
62 item
.setFarGuid(far
.getGuidValue());
63 item
.setStringValue(platformList
.get(i
));
64 GlobalData
.fdb
.getPlatformList().getFilenameList().add(item
);
67 DbPathAndFilename farItem
= DbPathAndFilename
.Factory
.newInstance();
68 farItem
.setFarGuid(far
.getGuidValue());
69 farItem
.setStringValue(far
.getFarName());
70 GlobalData
.fdb
.getFarList().getFilenameList().add(farItem
);
72 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
73 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
76 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
77 } catch (Exception e
) {
78 Log
.err("Save Database File", e
.getMessage());
82 public void removeFarFromDb(FarIdentification far
) {
86 XmlCursor cursor
= GlobalData
.fdb
.getPackageList().newCursor();
87 cursor
.toFirstChild();
89 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
91 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
94 } while (cursor
.toNextSibling());
100 cursor
= GlobalData
.fdb
.getPlatformList().newCursor();
101 cursor
.toFirstChild();
103 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
104 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
107 } while (cursor
.toNextSibling());
112 cursor
= GlobalData
.fdb
.getFarList().newCursor();
113 cursor
.toFirstChild();
115 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
116 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
119 } while (cursor
.toNextSibling());
122 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
123 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
125 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
126 } catch (Exception e
) {
127 Log
.err("Save Database File", e
.getMessage());
131 public String
getPackageFarGuid(Identification packageId
) {
132 for (int index
= 0; index
< GlobalData
.fdb
.getPackageList().getFilenameList().size(); index
++) {
133 DbPathAndFilename item
= GlobalData
.fdb
.getPackageList().getFilenameArray(index
);
134 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
135 File tempFile
= new File(path
);
136 if (tempFile
.getPath().equalsIgnoreCase(packageId
.getPath())) {
137 return GlobalData
.fdb
.getPackageList().getFilenameArray(index
).getFarGuid();
144 public String
getPlatformFarGuid(Identification platformId
) {
145 for (int index
= 0; index
< GlobalData
.fdb
.getPlatformList().getFilenameList().size(); index
++) {
146 DbPathAndFilename item
= GlobalData
.fdb
.getPlatformList().getFilenameArray(index
);
147 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
148 File tempFile
= new File(path
);
149 if (tempFile
.getPath().equalsIgnoreCase(platformId
.getPath())) {
150 return GlobalData
.fdb
.getPlatformList().getFilenameArray(index
).getFarGuid();
157 public String
getModuleFarGuid(Identification moduleId
) {
158 PackageIdentification packageId
= getPackageIdByModuleId(moduleId
);
159 if (packageId
!= null) {
160 return getPackageFarGuid(packageId
);
167 Get all modules' paths from one package
169 @return a Vector with all modules' path
172 public Vector
<String
> getAllModulesOfPackage(String path
) {
173 Vector
<String
> modulePath
= new Vector
<String
>();
174 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
175 MsaFiles files
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(id
).getMsaFiles();
177 for (int index
= 0; index
< files
.getFilenameList().size(); index
++) {
178 String msaPath
= files
.getFilenameList().get(index
);
179 msaPath
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + msaPath
;
180 msaPath
= Tools
.convertPathToCurrentOsType(msaPath
);
181 modulePath
.addElement(msaPath
);
189 Get all Industry Std Includes' paths from one package
191 @return a Vector with all paths
194 public Vector
<String
> getAllIndustryStdIncludesOfPackage(String path
) {
195 Vector
<String
> includePath
= new Vector
<String
>();
196 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
197 IndustryStdIncludes files
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(id
)
198 .getIndustryStdIncludes();
200 for (int index
= 0; index
< files
.getIndustryStdHeaderList().size(); index
++) {
201 String temp
= files
.getIndustryStdHeaderList().get(index
).getIncludeHeader();
202 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
203 temp
= Tools
.convertPathToCurrentOsType(temp
);
204 includePath
.addElement(temp
);
211 Get all package basic information form the FrameworkDatabase.db file
213 @return vPackageList A vector includes all packages' basic information
216 public Vector
<PackageIdentification
> getAllPackages() {
217 return GlobalData
.vPackageList
;
220 public Vector
<FarIdentification
> getAllFars() {
222 Vector
<FarIdentification
> v
= new Vector
<FarIdentification
>();
223 for (int index
= 0; index
< GlobalData
.fdb
.getFarList().getFilenameList().size(); index
++) {
224 DbPathAndFilename item
= GlobalData
.fdb
.getFarList().getFilenameList().get(index
);
225 FarIdentification far
= new FarIdentification(item
.getFarGuid(), item
.getMd5Sum(), item
.getStringValue());
231 public Vector
<PackageIdentification
> getPackagesByFar(FarIdentification far
) {
232 Identification id
= null;
234 Vector
<PackageIdentification
> v
= new Vector
<PackageIdentification
>();
236 for (int index
= 0; index
< GlobalData
.fdb
.getPackageList().getFilenameList().size(); index
++) {
237 DbPathAndFilename item
= GlobalData
.fdb
.getPackageList().getFilenameArray(index
);
238 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
239 path
= Tools
.convertPathToCurrentOsType(path
);
241 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
244 id
= Tools
.getId(path
, OpenFile
.openSpdFile(path
));
245 v
.addElement(new PackageIdentification(id
));
246 } catch (IOException e
) {
247 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
248 } catch (XmlException e
) {
249 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
250 } catch (Exception e
) {
251 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
258 public Vector
<PlatformIdentification
> getPlatformsByFar(FarIdentification far
) {
259 Identification id
= null;
261 Vector
<PlatformIdentification
> v
= new Vector
<PlatformIdentification
>();
263 for (int index
= 0; index
< GlobalData
.fdb
.getPlatformList().getFilenameList().size(); index
++) {
264 DbPathAndFilename item
= GlobalData
.fdb
.getPlatformList().getFilenameArray(index
);
265 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
266 path
= Tools
.convertPathToCurrentOsType(path
);
268 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
270 id
= Tools
.getId(path
, OpenFile
.openFpdFile(path
));
271 v
.addElement(new PlatformIdentification(id
));
272 } catch (IOException e
) {
273 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
274 } catch (XmlException e
) {
275 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
276 } catch (Exception e
) {
277 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
285 Get all module basic information from a package
288 @return A vector includes all modules' basic information
291 public Vector
<ModuleIdentification
> getAllModules(PackageIdentification pid
) {
292 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
293 Vector
<String
> modulePaths
= this.getAllModulesOfPackage(pid
.getPath());
294 String modulePath
= null;
296 for (int index
= 0; index
< modulePaths
.size(); index
++) {
297 modulePath
= modulePaths
.get(index
);
298 ModuleIdentification id
= GlobalData
.openingModuleList
.getIdByPath(modulePath
);
303 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
308 Get all module basic information from a platform
311 @return A vector includes all modules' basic information
314 public Vector
<ModuleIdentification
> getAllModules(PlatformIdentification fid
) {
315 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
316 PlatformSurfaceArea fpd
= GlobalData
.openingPlatformList
.getOpeningPlatformById(fid
).getXmlFpd();
317 if (fpd
.getFrameworkModules() != null) {
318 for (int index
= 0; index
< fpd
.getFrameworkModules().getModuleSAList().size(); index
++) {
319 String guid
= fpd
.getFrameworkModules().getModuleSAList().get(index
).getModuleGuid();
320 String version
= fpd
.getFrameworkModules().getModuleSAList().get(index
).getModuleVersion();
321 ModuleIdentification id
= GlobalData
.openingModuleList
.getIdByGuidVersion(guid
, version
);
323 boolean isFind
= false;
324 for (int indexOfModules
= 0; indexOfModules
< v
.size(); indexOfModules
++) {
325 if (v
.elementAt(indexOfModules
).equals(id
)) {
336 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
341 Get all module basic information form the FrameworkDatabase.db file
343 @return vModuleList A vector includes all modules' basic information
346 public Vector
<ModuleIdentification
> getAllModules() {
347 return GlobalData
.vModuleList
;
351 Get all platform basic information form the FrameworkDatabase.db file
353 @return vplatformList A vector includes all platforms' basic information
356 public Vector
<PlatformIdentification
> getAllPlatforms() {
357 return GlobalData
.vPlatformList
;
361 Get all Library Class Definitions from a package
365 public Vector
<String
> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd
) {
366 Vector
<String
> vector
= new Vector
<String
>();
367 if (spd
.getLibraryClassDeclarations() != null) {
368 if (spd
.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
369 for (int index
= 0; index
< spd
.getLibraryClassDeclarations().getLibraryClassList().size(); index
++) {
370 vector
.addElement(spd
.getLibraryClassDeclarations().getLibraryClassList().get(index
).getName());
374 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
379 Get all Protocol Definitions from a package
383 public Vector
<String
> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd
) {
384 Vector
<String
> vector
= new Vector
<String
>();
385 if (spd
.getProtocolDeclarations() != null) {
386 if (spd
.getProtocolDeclarations().getEntryList().size() > 0) {
387 for (int index
= 0; index
< spd
.getProtocolDeclarations().getEntryList().size(); index
++) {
388 vector
.addElement(spd
.getProtocolDeclarations().getEntryList().get(index
).getCName());
392 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
397 Get all Ppi Definitions from a package
401 public Vector
<String
> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd
) {
402 Vector
<String
> vector
= new Vector
<String
>();
403 if (spd
.getPpiDeclarations() != null) {
404 if (spd
.getPpiDeclarations().getEntryList().size() > 0) {
405 for (int index
= 0; index
< spd
.getPpiDeclarations().getEntryList().size(); index
++) {
406 vector
.addElement(spd
.getPpiDeclarations().getEntryList().get(index
).getCName());
410 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
415 Get all Guid Definitions from a package
419 public Vector
<String
> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd
) {
420 Vector
<String
> vector
= new Vector
<String
>();
421 if (spd
.getGuidDeclarations() != null) {
422 if (spd
.getGuidDeclarations().getEntryList().size() > 0) {
423 for (int index
= 0; index
< spd
.getGuidDeclarations().getEntryList().size(); index
++) {
424 vector
.addElement(spd
.getGuidDeclarations().getEntryList().get(index
).getCName());
428 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
433 Get all Pcd Definitions from a package
437 public PcdVector
getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd
) {
438 PcdVector vector
= new PcdVector();
439 if (spd
.getPcdDeclarations() != null) {
440 if (spd
.getPcdDeclarations().getPcdEntryList().size() > 0) {
441 for (int index
= 0; index
< spd
.getPcdDeclarations().getPcdEntryList().size(); index
++) {
442 String name
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getCName();
443 String guidCName
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getTokenSpaceGuidCName();
444 String help
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getHelpText();
445 Vector
<String
> type
= Tools
.convertListToVector(spd
.getPcdDeclarations().getPcdEntryList()
446 .get(index
).getValidUsage());
448 vector
.addPcd(new PcdIdentification(name
, guidCName
, help
, type
));
452 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
456 public Vector
<String
> getAllLibraryClassDefinitionsFromWorkspace() {
457 Vector
<String
> vector
= new Vector
<String
>();
458 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
459 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(GlobalData
.openingPackageList
460 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
462 if (v
!= null && v
.size() > 0) {
467 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
471 public Vector
<String
> getAllLibraryClassDefinitionsFromPackages(Vector
<PackageIdentification
> vpid
) {
472 Vector
<String
> vector
= new Vector
<String
>();
473 for (int index
= 0; index
< vpid
.size(); index
++) {
474 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(GlobalData
.openingPackageList
475 .getPackageSurfaceAreaFromId(vpid
477 if (v
!= null && v
.size() > 0) {
482 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
486 public Vector
<String
> getAllProtocolDeclarationsFromWorkspace() {
487 Vector
<String
> vector
= new Vector
<String
>();
488 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
489 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(GlobalData
.openingPackageList
490 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
492 if (v
!= null && v
.size() > 0) {
496 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
500 public Vector
<String
> getAllProtocolDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
501 Vector
<String
> vector
= new Vector
<String
>();
502 for (int index
= 0; index
< vpid
.size(); index
++) {
503 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(GlobalData
.openingPackageList
504 .getPackageSurfaceAreaFromId(vpid
506 if (v
!= null && v
.size() > 0) {
510 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
514 public Vector
<String
> getAllPpiDeclarationsFromWorkspace() {
515 Vector
<String
> vector
= new Vector
<String
>();
516 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
517 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(GlobalData
.openingPackageList
518 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
520 if (v
!= null && v
.size() > 0) {
524 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
528 public Vector
<String
> getAllPpiDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
529 Vector
<String
> vector
= new Vector
<String
>();
530 for (int index
= 0; index
< vpid
.size(); index
++) {
531 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(GlobalData
.openingPackageList
532 .getPackageSurfaceAreaFromId(vpid
534 if (v
!= null && v
.size() > 0) {
538 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
542 public Vector
<String
> getAllGuidDeclarationsFromWorkspace() {
543 Vector
<String
> vector
= new Vector
<String
>();
544 for (int index
= 0; index
< GlobalData
.vPackageList
.size(); index
++) {
545 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(GlobalData
.openingPackageList
546 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
548 if (v
!= null && v
.size() > 0) {
553 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
557 public Vector
<String
> getAllGuidDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
558 Vector
<String
> vector
= new Vector
<String
>();
559 for (int index
= 0; index
< vpid
.size(); index
++) {
560 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(GlobalData
.openingPackageList
561 .getPackageSurfaceAreaFromId(vpid
563 if (v
!= null && v
.size() > 0) {
568 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
572 public PcdVector
getAllPcdDeclarationsFromWorkspace() {
573 PcdVector vector
= new PcdVector();
574 for (int index
= 0; index
< GlobalData
.openingPackageList
.size(); index
++) {
575 PcdVector v
= getAllPcdDeclarationsFromPackage(GlobalData
.openingPackageList
576 .getPackageSurfaceAreaFromId(GlobalData
.vPackageList
578 if (v
!= null && v
.size() > 0) {
583 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
587 public PcdVector
getAllPcdDeclarationsFromPackages(Vector
<PackageIdentification
> vpid
) {
588 PcdVector vector
= new PcdVector();
589 for (int index
= 0; index
< vpid
.size(); index
++) {
590 PcdVector v
= getAllPcdDeclarationsFromPackage(GlobalData
.openingPackageList
591 .getPackageSurfaceAreaFromId(vpid
593 if (v
!= null && v
.size() > 0) {
598 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
603 Find a module's package's id
605 @param id input module id
609 public PackageIdentification
getPackageIdByModuleId(Identification id
) {
610 Vector
<String
> modulePaths
= new Vector
<String
>();
611 Identification mid
= null;
612 String packagePath
= null;
613 String modulePath
= null;
616 // For each package, get all modules list
618 for (int indexI
= 0; indexI
< GlobalData
.vPackageList
.size(); indexI
++) {
619 packagePath
= GlobalData
.vPackageList
.elementAt(indexI
).getPath();
620 modulePaths
= this.getAllModulesOfPackage(packagePath
);
621 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
622 modulePath
= modulePaths
.get(indexJ
);
623 mid
= GlobalData
.openingModuleList
.getIdByPath(modulePath
);
627 if (mid
.equals(id
)) {
628 return GlobalData
.vPackageList
.elementAt(indexI
);
638 Add module information to package surface area
646 public void addModuleToPackage(ModuleIdentification mid
, PackageSurfaceArea spd
) throws IOException
, XmlException
,
648 String packagePath
= mid
.getPackageId().getPath();
649 String modulePath
= mid
.getPath();
651 spd
= OpenFile
.openSpdFile(packagePath
);
653 MsaFiles msaFile
= spd
.getMsaFiles();
654 if (msaFile
== null) {
655 msaFile
= MsaFiles
.Factory
.newInstance();
657 packagePath
= packagePath
.substring(0, packagePath
.lastIndexOf(DataType
.FILE_SEPARATOR
));
658 String fn
= Tools
.getRelativePath(modulePath
, packagePath
);
659 msaFile
.addNewFilename();
660 msaFile
.setFilenameArray(msaFile
.getFilenameList().size() - 1, fn
);
661 spd
.setMsaFiles(msaFile
);
662 SaveFile
.saveSpdFile(mid
.getPackageId().getPath(), spd
);
666 Add input package into database
672 public void addPackageToDatabase(PackageIdentification id
) throws Exception
{
673 String path
= id
.getPath();
674 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
676 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
677 filename
.setStringValue(path
);
678 GlobalData
.fdb
.getPackageList().addNewFilename();
679 GlobalData
.fdb
.getPackageList().setFilenameArray(GlobalData
.fdb
.getPackageList().sizeOfFilenameArray() - 1,
681 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
682 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
683 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
687 Add input package into database
693 public void addPlatformToDatabase(PlatformIdentification id
) throws Exception
{
694 String path
= id
.getPath();
695 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
697 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
698 filename
.setStringValue(path
);
699 GlobalData
.fdb
.getPlatformList().addNewFilename();
700 GlobalData
.fdb
.getPlatformList().setFilenameArray(GlobalData
.fdb
.getPlatformList().sizeOfFilenameArray() - 1,
702 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
703 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
704 SaveFile
.saveDbFile(strFrameworkDbFilePath
, GlobalData
.fdb
);
708 Get all file's path from one module
717 public Vector
<String
> getAllFilesPathOfModule(String path
) {
718 Vector
<String
> v
= new Vector
<String
>();
719 path
= Tools
.convertPathToCurrentOsType(path
);
721 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
722 .getModuleSurfaceAreaFromId(GlobalData
.openingModuleList
726 // Get all files' path of a module
728 SourceFiles sf
= msa
.getSourceFiles();
730 for (int index
= 0; index
< sf
.getFilenameList().size(); index
++) {
731 String temp
= sf
.getFilenameList().get(index
).getStringValue();
732 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
733 v
.addElement(Tools
.convertPathToCurrentOsType(temp
));
742 Get all file's path from one package
751 public Vector
<String
> getAllFilesPathOfPakcage(String path
) {
752 Vector
<String
> v
= new Vector
<String
>();
753 path
= Tools
.convertPathToCurrentOsType(path
);
760 // Add the package's industry std includes one by one
762 Vector
<String
> f1
= new Vector
<String
>();
763 f1
= getAllIndustryStdIncludesOfPackage(path
);
764 for (int index
= 0; index
< f1
.size(); index
++) {
765 v
.addElement(f1
.get(index
));
769 // Add module's files one by one
771 f1
= new Vector
<String
>();
772 f1
= getAllModulesOfPackage(path
);
773 for (int indexI
= 0; indexI
< f1
.size(); indexI
++) {
774 Vector
<String
> f2
= getAllFilesPathOfModule(f1
.get(indexI
));
775 for (int indexJ
= 0; indexJ
< f2
.size(); indexJ
++) {
776 v
.addElement(f2
.get(indexJ
));
784 Get a module's all package dependencies
786 @param mid The module id
787 @return A vector of all package dependency ids
790 public Vector
<PackageIdentification
> getPackageDependenciesOfModule(ModuleIdentification mid
) {
791 Vector
<PackageIdentification
> vpid
= new Vector
<PackageIdentification
>();
792 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(mid
);
794 PackageDependencies pd
= msa
.getPackageDependencies();
796 for (int index
= 0; index
< pd
.getPackageList().size(); index
++) {
797 String guid
= pd
.getPackageList().get(index
).getPackageGuid();
798 String version
= pd
.getPackageList().get(index
).getPackageVersion();
799 PackageIdentification pid
= GlobalData
.openingPackageList
.getIdByGuidVersion(guid
, version
);
801 vpid
.addElement(pid
);
809 public Vector
<String
> getAllModuleGuidXref() {
810 Vector
<String
> v
= new Vector
<String
>();
811 for (int index
= 0; index
< GlobalData
.openingModuleList
.size(); index
++) {
812 ModuleIdentification id
= GlobalData
.openingModuleList
.getOpeningModuleByIndex(index
).getId();
813 v
.addElement(id
.getGuid() + " " + id
.getName());
818 public Vector
<String
> getModuleArch(ModuleIdentification id
) {
819 Vector
<String
> v
= new Vector
<String
>();
820 ModuleSurfaceArea msa
= null;
822 msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(id
);
825 if (msa
.getModuleDefinitions() != null) {
826 v
= Tools
.convertListToVector(msa
.getModuleDefinitions().getSupportedArchitectures());