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
.FrameworkDatabaseDocument
.FrameworkDatabase
;
26 import org
.tianocore
.IndustryStdIncludesDocument
.IndustryStdIncludes
;
27 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
28 import org
.tianocore
.MsaFilesDocument
.MsaFiles
;
29 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
30 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
31 import org
.tianocore
.PlatformHeaderDocument
.PlatformHeader
;
32 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
33 import org
.tianocore
.SourceFilesDocument
.SourceFiles
;
34 import org
.tianocore
.SpdHeaderDocument
.SpdHeader
;
35 import org
.tianocore
.frameworkwizard
.common
.DataType
;
36 import org
.tianocore
.frameworkwizard
.common
.Log
;
37 import org
.tianocore
.frameworkwizard
.common
.OpenFile
;
38 import org
.tianocore
.frameworkwizard
.common
.SaveFile
;
39 import org
.tianocore
.frameworkwizard
.common
.Sort
;
40 import org
.tianocore
.frameworkwizard
.common
.Tools
;
41 import org
.tianocore
.frameworkwizard
.common
.Identifications
.Identification
;
42 import org
.tianocore
.frameworkwizard
.far
.FarHeader
;
43 import org
.tianocore
.frameworkwizard
.far
.FarIdentification
;
44 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
45 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdIdentification
;
46 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdVector
;
47 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
48 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
50 public class WorkspaceTools
{
52 // Define class members
54 private FrameworkDatabase fdb
= null;
56 private Vector
<ModuleIdentification
> vModuleList
= new Vector
<ModuleIdentification
>();
58 private Vector
<PackageIdentification
> vPackageList
= new Vector
<PackageIdentification
>();
60 private Vector
<PlatformIdentification
> vPlatformList
= new Vector
<PlatformIdentification
>();
64 Open Framework Database file
67 private FrameworkDatabase
openFrameworkDb() {
68 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
69 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
71 fdb
= OpenFile
.openFrameworkDb(strFrameworkDbFilePath
);
72 } catch (XmlException e
) {
73 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, e
.getMessage());
75 } catch (Exception e
) {
76 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, "Invalid file type");
82 public void addFarToDb(List
<String
> packageList
, List
<String
> platformList
, FarHeader far
) {
83 FrameworkDatabase fdb
= openFrameworkDb();
85 for (int i
= 0; i
< packageList
.size(); i
++) {
86 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
87 item
.setFarGuid(far
.getGuidValue());
88 item
.setStringValue(packageList
.get(i
));
89 fdb
.getPackageList().getFilenameList().add(item
);
92 for (int i
= 0; i
< platformList
.size(); i
++) {
93 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
94 item
.setFarGuid(far
.getGuidValue());
95 item
.setStringValue(platformList
.get(i
));
96 fdb
.getPlatformList().getFilenameList().add(item
);
99 DbPathAndFilename farItem
= DbPathAndFilename
.Factory
.newInstance();
100 farItem
.setFarGuid(far
.getGuidValue());
101 farItem
.setStringValue(far
.getFarName());
102 fdb
.getFarList().getFilenameList().add(farItem
);
104 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
105 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
108 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
109 } catch (Exception e
) {
110 Log
.err("Save Database File", e
.getMessage());
114 public void removeFarFromDb(FarIdentification far
) {
115 FrameworkDatabase fdb
= openFrameworkDb();
119 XmlCursor cursor
= fdb
.getPackageList().newCursor();
120 cursor
.toFirstChild();
122 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
124 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
127 } while (cursor
.toNextSibling());
133 cursor
= fdb
.getPlatformList().newCursor();
134 cursor
.toFirstChild();
136 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
137 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
140 } while (cursor
.toNextSibling());
145 cursor
= fdb
.getFarList().newCursor();
146 cursor
.toFirstChild();
148 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
149 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
152 } while (cursor
.toNextSibling());
155 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
156 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
158 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
159 } catch (Exception e
) {
160 Log
.err("Save Database File", e
.getMessage());
164 public String
getPackageFarGuid(Identification packageId
) {
167 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
168 DbPathAndFilename item
= fdb
.getPackageList().getFilenameArray(index
);
169 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
170 File tempFile
= new File(path
);
171 if (tempFile
.getPath().equalsIgnoreCase(packageId
.getPath())) {
172 return fdb
.getPackageList().getFilenameArray(index
).getFarGuid();
179 public String
getPlatformFarGuid(Identification platformId
) {
182 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
183 DbPathAndFilename item
= fdb
.getPlatformList().getFilenameArray(index
);
184 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
185 File tempFile
= new File(path
);
186 if (tempFile
.getPath().equalsIgnoreCase(platformId
.getPath())) {
187 return fdb
.getPlatformList().getFilenameArray(index
).getFarGuid();
194 public String
getModuleFarGuid(Identification moduleId
) {
195 PackageIdentification packageId
= getPackageIdByModuleId(moduleId
);
196 if (packageId
!= null) {
197 return getPackageFarGuid(packageId
);
204 Get all modules' paths from one package
206 @return a Vector with all modules' path
209 public Vector
<String
> getAllModulesOfPackage(String path
) {
210 Vector
<String
> modulePath
= new Vector
<String
>();
212 MsaFiles files
= OpenFile
.openSpdFile(path
).getMsaFiles();
214 for (int index
= 0; index
< files
.getFilenameList().size(); index
++) {
215 String msaPath
= files
.getFilenameList().get(index
);
216 msaPath
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + msaPath
;
217 msaPath
= Tools
.convertPathToCurrentOsType(msaPath
);
218 modulePath
.addElement(msaPath
);
221 } catch (IOException e
) {
222 Log
.err("Get all mdoules of a package " + path
, e
.getMessage());
223 } catch (XmlException e
) {
224 Log
.err("Get all mdoules of a package " + path
, e
.getMessage());
225 } catch (Exception e
) {
226 Log
.err("Get all mdoules of a package " + path
, e
.getMessage());
232 Get all Industry Std Includes' paths from one package
234 @return a Vector with all paths
237 public Vector
<String
> getAllIndustryStdIncludesOfPackage(String path
) {
238 Vector
<String
> includePath
= new Vector
<String
>();
240 IndustryStdIncludes files
= OpenFile
.openSpdFile(path
).getIndustryStdIncludes();
242 for (int index
= 0; index
< files
.getIndustryStdHeaderList().size(); index
++) {
243 String temp
= files
.getIndustryStdHeaderList().get(index
).getIncludeHeader();
244 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
245 temp
= Tools
.convertPathToCurrentOsType(temp
);
246 includePath
.addElement(temp
);
249 } catch (IOException e
) {
250 Log
.err("Get all Industry Std Includes of a package " + path
, e
.getMessage());
251 } catch (XmlException e
) {
252 Log
.err("Get all Industry Std Includes of a package " + path
, e
.getMessage());
253 } catch (Exception e
) {
254 Log
.err("Get all Industry Std Includes of a package " + path
, e
.getMessage());
260 Get all package basic information form the FrameworkDatabase.db file
262 @return vPackageList A vector includes all packages' basic information
265 public Vector
<PackageIdentification
> getAllPackages() {
266 Identification id
= null;
267 vPackageList
.removeAllElements();
271 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
272 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
273 + fdb
.getPackageList().getFilenameArray(index
).getStringValue();
274 path
= Tools
.convertPathToCurrentOsType(path
);
276 id
= getId(path
, OpenFile
.openSpdFile(path
));
277 vPackageList
.addElement(new PackageIdentification(id
));
278 } catch (IOException e
) {
279 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
280 } catch (XmlException e
) {
281 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
282 } catch (Exception e
) {
283 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
286 Sort
.sortPackages(vPackageList
, DataType
.SORT_TYPE_ASCENDING
);
290 public Vector
<FarIdentification
> getAllFars() {
292 Vector
<FarIdentification
> v
= new Vector
<FarIdentification
>();
293 for (int index
= 0; index
< fdb
.getFarList().getFilenameList().size(); index
++) {
294 DbPathAndFilename item
= fdb
.getFarList().getFilenameList().get(index
);
295 FarIdentification far
= new FarIdentification(item
.getFarGuid(), item
.getMd5Sum(), item
.getStringValue());
301 public Vector
<PackageIdentification
> getPackagesByFar(FarIdentification far
) {
302 Identification id
= null;
304 Vector
<PackageIdentification
> v
= new Vector
<PackageIdentification
>();
306 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
307 DbPathAndFilename item
= fdb
.getPackageList().getFilenameArray(index
);
308 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
309 path
= Tools
.convertPathToCurrentOsType(path
);
311 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
314 id
= getId(path
, OpenFile
.openSpdFile(path
));
315 v
.addElement(new PackageIdentification(id
));
316 } catch (IOException e
) {
317 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
318 } catch (XmlException e
) {
319 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
320 } catch (Exception e
) {
321 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
328 public Vector
<PlatformIdentification
> getPlatformsByFar(FarIdentification far
) {
329 Identification id
= null;
331 Vector
<PlatformIdentification
> v
= new Vector
<PlatformIdentification
>();
333 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
334 DbPathAndFilename item
= fdb
.getPlatformList().getFilenameArray(index
);
335 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
336 path
= Tools
.convertPathToCurrentOsType(path
);
338 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
340 id
= getId(path
, OpenFile
.openFpdFile(path
));
341 v
.addElement(new PlatformIdentification(id
));
342 } catch (IOException e
) {
343 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
344 } catch (XmlException e
) {
345 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
346 } catch (Exception e
) {
347 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
355 Get all module basic information from a package
358 @return A vector includes all modules' basic information
361 public Vector
<ModuleIdentification
> getAllModules(PackageIdentification pid
) {
362 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
363 Vector
<String
> modulePaths
= this.getAllModulesOfPackage(pid
.getPath());
364 Identification id
= null;
365 String modulePath
= null;
367 for (int index
= 0; index
< modulePaths
.size(); index
++) {
369 modulePath
= modulePaths
.get(index
);
370 id
= getId(modulePath
, OpenFile
.openMsaFile(modulePath
));
371 } catch (IOException e
) {
372 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
373 } catch (XmlException e
) {
374 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
375 } catch (Exception e
) {
376 Log
.err("Open Module Surface Area " + modulePath
, "Invalid file type " + e
.getMessage());
378 v
.addElement(new ModuleIdentification(id
, pid
));
380 Sort
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
386 Get all module basic information form the FrameworkDatabase.db file
388 @return vModuleList A vector includes all modules' basic information
391 public Vector
<ModuleIdentification
> getAllModules() {
392 vModuleList
.removeAllElements();
394 // First get all packages
397 Vector
<String
> modulePaths
= new Vector
<String
>();
398 Identification id
= null;
399 String packagePath
= null;
400 String modulePath
= null;
403 // For each package, get all modules list
405 for (int indexI
= 0; indexI
< vPackageList
.size(); indexI
++) {
406 packagePath
= vPackageList
.elementAt(indexI
).getPath();
407 modulePaths
= this.getAllModulesOfPackage(packagePath
);
409 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
411 modulePath
= modulePaths
.get(indexJ
);
412 id
= getId(modulePath
, OpenFile
.openMsaFile(modulePath
));
413 vModuleList
.addElement(new ModuleIdentification(id
, vPackageList
.elementAt(indexI
)));
414 } catch (IOException e
) {
415 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
416 } catch (XmlException e
) {
417 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
418 } catch (Exception e
) {
419 Log
.err("Open Module Surface Area " + modulePath
, "Invalid file type");
423 Sort
.sortModules(vModuleList
, DataType
.SORT_TYPE_ASCENDING
);
428 Get all platform basic information form the FrameworkDatabase.db file
430 @return vplatformList A vector includes all platforms' basic information
433 public Vector
<PlatformIdentification
> getAllPlatforms() {
434 Identification id
= null;
435 vPlatformList
.removeAllElements();
439 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
440 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
441 + fdb
.getPlatformList().getFilenameArray(index
).getStringValue();
442 path
= Tools
.convertPathToCurrentOsType(path
);
444 id
= getId(path
, OpenFile
.openFpdFile(path
));
445 vPlatformList
.addElement(new PlatformIdentification(id
));
446 } catch (IOException e
) {
447 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
448 } catch (XmlException e
) {
449 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
450 } catch (Exception e
) {
451 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
454 Sort
.sortPlatforms(vPlatformList
, DataType
.SORT_TYPE_ASCENDING
);
455 return vPlatformList
;
459 Get all Library Class Definitions from a package
463 public Vector
<String
> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd
) {
464 Vector
<String
> vector
= new Vector
<String
>();
465 if (spd
.getLibraryClassDeclarations() != null) {
466 if (spd
.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
467 for (int index
= 0; index
< spd
.getLibraryClassDeclarations().getLibraryClassList().size(); index
++) {
468 vector
.addElement(spd
.getLibraryClassDeclarations().getLibraryClassList().get(index
).getName());
472 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
477 Get all Protocol Definitions from a package
481 public Vector
<String
> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd
) {
482 Vector
<String
> vector
= new Vector
<String
>();
483 if (spd
.getProtocolDeclarations() != null) {
484 if (spd
.getProtocolDeclarations().getEntryList().size() > 0) {
485 for (int index
= 0; index
< spd
.getProtocolDeclarations().getEntryList().size(); index
++) {
486 vector
.addElement(spd
.getProtocolDeclarations().getEntryList().get(index
).getCName());
490 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
495 Get all Ppi Definitions from a package
499 public Vector
<String
> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd
) {
500 Vector
<String
> vector
= new Vector
<String
>();
501 if (spd
.getPpiDeclarations() != null) {
502 if (spd
.getPpiDeclarations().getEntryList().size() > 0) {
503 for (int index
= 0; index
< spd
.getPpiDeclarations().getEntryList().size(); index
++) {
504 vector
.addElement(spd
.getPpiDeclarations().getEntryList().get(index
).getCName());
508 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
513 Get all Guid Definitions from a package
517 public Vector
<String
> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd
) {
518 Vector
<String
> vector
= new Vector
<String
>();
519 if (spd
.getGuidDeclarations() != null) {
520 if (spd
.getGuidDeclarations().getEntryList().size() > 0) {
521 for (int index
= 0; index
< spd
.getGuidDeclarations().getEntryList().size(); index
++) {
522 vector
.addElement(spd
.getGuidDeclarations().getEntryList().get(index
).getCName());
526 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
531 Get all Pcd Definitions from a package
535 public PcdVector
getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd
) {
536 PcdVector vector
= new PcdVector();
537 if (spd
.getPcdDeclarations() != null) {
538 if (spd
.getPcdDeclarations().getPcdEntryList().size() > 0) {
539 for (int index
= 0; index
< spd
.getPcdDeclarations().getPcdEntryList().size(); index
++) {
540 String name
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getCName();
541 String guidCName
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getTokenSpaceGuidCName();
542 String help
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getHelpText();
543 Vector
<String
> type
= Tools
.convertListToVector(spd
.getPcdDeclarations().getPcdEntryList()
544 .get(index
).getValidUsage());
546 vector
.addPcd(new PcdIdentification(name
, guidCName
, help
, type
));
550 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
554 public Vector
<String
> getAllLibraryClassDefinitionsFromWorkspace() {
556 // First get all packages
558 this.getAllPackages();
560 Vector
<String
> vector
= new Vector
<String
>();
561 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
563 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(OpenFile
564 .openSpdFile(vPackageList
567 if (v
!= null && v
.size() > 0) {
570 } catch (IOException e
) {
571 Log
.err("getAllLibraryClassDefinitionsFromWorkspace ", e
.getMessage());
572 } catch (XmlException e
) {
573 Log
.err("getAllLibraryClassDefinitionsFromWorkspace ", e
.getMessage());
574 } catch (Exception e
) {
575 Log
.err("getAllLibraryClassDefinitionsFromWorkspace ", e
.getMessage());
578 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
582 public Vector
<String
> getAllProtocolDeclarationsFromWorkspace() {
584 // First get all packages
586 this.getAllPackages();
588 Vector
<String
> vector
= new Vector
<String
>();
589 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
591 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
)
593 if (v
!= null && v
.size() > 0) {
596 } catch (IOException e
) {
597 Log
.err("getAllProtocolDeclarationsFromPackage", e
.getMessage());
598 } catch (XmlException e
) {
599 Log
.err("getAllProtocolDeclarationsFromPackage", e
.getMessage());
600 } catch (Exception e
) {
601 Log
.err("getAllProtocolDeclarationsFromPackage", e
.getMessage());
604 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
608 public Vector
<String
> getAllPpiDeclarationsFromWorkspace() {
610 // First get all packages
612 this.getAllPackages();
614 Vector
<String
> vector
= new Vector
<String
>();
615 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
617 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
)
619 if (v
!= null && v
.size() > 0) {
622 } catch (IOException e
) {
623 Log
.err("getAllPpiDeclarationsFromWorkspace", e
.getMessage());
624 } catch (XmlException e
) {
625 Log
.err("getAllPpiDeclarationsFromWorkspace", e
.getMessage());
626 } catch (Exception e
) {
627 Log
.err("getAllPpiDeclarationsFromWorkspace", e
.getMessage());
630 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
634 public Vector
<String
> getAllGuidDeclarationsFromWorkspace() {
636 // First get all packages
638 this.getAllPackages();
640 Vector
<String
> vector
= new Vector
<String
>();
641 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
643 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
)
645 if (v
!= null && v
.size() > 0) {
648 } catch (IOException e
) {
649 Log
.err("getAllGuidDeclarationsFromWorkspace", e
.getMessage());
650 } catch (XmlException e
) {
651 Log
.err("getAllGuidDeclarationsFromWorkspace", e
.getMessage());
652 } catch (Exception e
) {
653 Log
.err("getAllGuidDeclarationsFromWorkspace", e
.getMessage());
656 Sort
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
660 public PcdVector
getAllPcdDeclarationsFromWorkspace() {
662 // First get all packages
664 this.getAllPackages();
666 PcdVector vector
= new PcdVector();
667 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
669 PcdVector v
= getAllPcdDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
).getPath()));
670 if (v
!= null && v
.size() > 0) {
673 } catch (IOException e
) {
674 Log
.err("getAllPcdDeclarationsFromWorkspace", e
.getMessage());
675 } catch (XmlException e
) {
676 Log
.err("getAllPcdDeclarationsFromWorkspace", e
.getMessage());
677 } catch (Exception e
) {
678 Log
.err("getAllPcdDeclarationsFromWorkspace", e
.getMessage());
681 Sort
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
686 Find a module's package's id
688 @param id input module id
692 public PackageIdentification
getPackageIdByModuleId(Identification id
) {
694 Vector
<String
> modulePaths
= new Vector
<String
>();
695 Identification mid
= null;
696 String packagePath
= null;
697 String modulePath
= null;
700 // For each package, get all modules list
702 for (int indexI
= 0; indexI
< vPackageList
.size(); indexI
++) {
703 packagePath
= vPackageList
.elementAt(indexI
).getPath();
704 modulePaths
= this.getAllModulesOfPackage(packagePath
);
705 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
706 modulePath
= modulePaths
.get(indexJ
);
708 mid
= getId(modulePath
, OpenFile
.openMsaFile(modulePath
));
712 if (mid
.equals(id
)) {
713 return vPackageList
.elementAt(indexI
);
715 } catch (IOException e
) {
716 Log
.err("getPackageIdByModuleId " + id
.getPath(), e
.getMessage());
717 } catch (XmlException e
) {
718 Log
.err("getPackageIdByModuleId " + id
.getPath(), e
.getMessage());
719 } catch (Exception e
) {
720 Log
.err("getPackageIdByModuleId " + id
.getPath(), e
.getMessage());
728 public Identification
getId(String path
, ModuleSurfaceArea msa
) {
729 MsaHeader head
= msa
.getMsaHeader();
730 String name
= head
.getModuleName();
731 String guid
= head
.getGuidValue();
732 String version
= head
.getVersion();
733 Identification id
= new Identification(name
, guid
, version
, path
);
737 public Identification
getId(String path
, PackageSurfaceArea spd
) {
738 SpdHeader head
= spd
.getSpdHeader();
739 String name
= head
.getPackageName();
740 String guid
= head
.getGuidValue();
741 String version
= head
.getVersion();
742 Identification id
= new Identification(name
, guid
, version
, path
);
746 public Identification
getId(String path
, PlatformSurfaceArea fpd
) {
747 PlatformHeader head
= fpd
.getPlatformHeader();
748 String name
= head
.getPlatformName();
749 String guid
= head
.getGuidValue();
750 String version
= head
.getVersion();
751 Identification id
= new Identification(name
, guid
, version
, path
);
756 Add module information to package surface area
764 public void addModuleToPackage(ModuleIdentification mid
, PackageSurfaceArea spd
) throws IOException
, XmlException
,
766 String packagePath
= mid
.getPackageId().getPath();
767 String modulePath
= mid
.getPath();
769 spd
= OpenFile
.openSpdFile(packagePath
);
771 MsaFiles msaFile
= spd
.getMsaFiles();
772 if (msaFile
== null) {
773 msaFile
= MsaFiles
.Factory
.newInstance();
775 packagePath
= packagePath
.substring(0, packagePath
.lastIndexOf(DataType
.FILE_SEPARATOR
));
776 String fn
= Tools
.getRelativePath(modulePath
, packagePath
);
777 msaFile
.addNewFilename();
778 msaFile
.setFilenameArray(msaFile
.getFilenameList().size() - 1, fn
);
779 spd
.setMsaFiles(msaFile
);
780 SaveFile
.saveSpdFile(mid
.getPackageId().getPath(), spd
);
784 Add input package into database
790 public void addPackageToDatabase(PackageIdentification id
) throws Exception
{
791 String path
= id
.getPath();
792 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
793 this.openFrameworkDb();
794 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
795 filename
.setStringValue(path
);
796 fdb
.getPackageList().addNewFilename();
797 fdb
.getPackageList().setFilenameArray(fdb
.getPackageList().sizeOfFilenameArray() - 1, filename
);
798 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
799 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
800 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
804 Add input package into database
810 public void addPlatformToDatabase(PlatformIdentification id
) throws Exception
{
811 String path
= id
.getPath();
812 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
813 this.openFrameworkDb();
814 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
815 filename
.setStringValue(path
);
816 fdb
.getPlatformList().addNewFilename();
817 fdb
.getPlatformList().setFilenameArray(fdb
.getPlatformList().sizeOfFilenameArray() - 1, filename
);
818 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
819 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
820 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
824 Get all file's path from one module
833 public Vector
<String
> getAllModuleFilesPath(String path
) throws IOException
, XmlException
, Exception
{
834 Vector
<String
> v
= new Vector
<String
>();
835 path
= Tools
.convertPathToCurrentOsType(path
);
837 ModuleSurfaceArea msa
= OpenFile
.openMsaFile(path
);
840 // Get all files' path of a module
842 SourceFiles sf
= msa
.getSourceFiles();
844 for (int index
= 0; index
< sf
.getFilenameList().size(); index
++) {
845 String temp
= sf
.getFilenameList().get(index
).getStringValue();
846 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
847 v
.addElement(Tools
.convertPathToCurrentOsType(temp
));
856 Get all file's path from one package
865 public Vector
<String
> getAllPakcageFilesPath(String path
) throws IOException
, XmlException
, Exception
{
866 Vector
<String
> v
= new Vector
<String
>();
867 path
= Tools
.convertPathToCurrentOsType(path
);
874 // Add the package's industry std includes one by one
876 Vector
<String
> f1
= new Vector
<String
>();
877 f1
= getAllIndustryStdIncludesOfPackage(path
);
878 for (int index
= 0; index
< f1
.size(); index
++) {
879 v
.addElement(f1
.get(index
));
883 // Add module's files one by one
885 f1
= new Vector
<String
>();
886 f1
= getAllModulesOfPackage(path
);
887 for (int indexI
= 0; indexI
< f1
.size(); indexI
++) {
888 Vector
<String
> f2
= getAllModuleFilesPath(f1
.get(indexI
));
889 for (int indexJ
= 0; indexJ
< f2
.size(); indexJ
++) {
890 v
.addElement(f2
.get(indexJ
));