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
.SaveFile
;
38 import org
.tianocore
.frameworkwizard
.common
.Tools
;
39 import org
.tianocore
.frameworkwizard
.common
.Identifications
.Identification
;
40 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpenFile
;
41 import org
.tianocore
.frameworkwizard
.far
.FarHeader
;
42 import org
.tianocore
.frameworkwizard
.far
.FarIdentification
;
43 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
44 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdIdentification
;
45 import org
.tianocore
.frameworkwizard
.module
.Identifications
.PcdCoded
.PcdVector
;
46 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
47 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
49 public class WorkspaceTools
{
51 // Define class members
53 private FrameworkDatabase fdb
= null;
55 private Vector
<ModuleIdentification
> vModuleList
= new Vector
<ModuleIdentification
>();
57 private Vector
<PackageIdentification
> vPackageList
= new Vector
<PackageIdentification
>();
59 private Vector
<PlatformIdentification
> vPlatformList
= new Vector
<PlatformIdentification
>();
63 Open Framework Database file
66 private FrameworkDatabase
openFrameworkDb() {
67 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
68 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
70 fdb
= OpenFile
.openFrameworkDb(strFrameworkDbFilePath
);
71 } catch (XmlException e
) {
72 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, e
.getMessage());
74 } catch (Exception e
) {
75 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, "Invalid file type");
81 public void addFarToDb(List
<String
> packageList
, List
<String
> platformList
, FarHeader far
) {
82 FrameworkDatabase fdb
= openFrameworkDb();
84 for (int i
= 0; i
< packageList
.size(); i
++) {
85 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
86 item
.setFarGuid(far
.getGuidValue());
87 item
.setStringValue(packageList
.get(i
));
88 fdb
.getPackageList().getFilenameList().add(item
);
91 for (int i
= 0; i
< platformList
.size(); i
++) {
92 DbPathAndFilename item
= DbPathAndFilename
.Factory
.newInstance();
93 item
.setFarGuid(far
.getGuidValue());
94 item
.setStringValue(platformList
.get(i
));
95 fdb
.getPlatformList().getFilenameList().add(item
);
98 DbPathAndFilename farItem
= DbPathAndFilename
.Factory
.newInstance();
99 farItem
.setFarGuid(far
.getGuidValue());
100 farItem
.setStringValue(far
.getFarName());
101 fdb
.getFarList().getFilenameList().add(farItem
);
103 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
104 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
107 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
108 } catch (Exception e
) {
113 public void removeFarFromDb(FarIdentification far
) {
114 FrameworkDatabase fdb
= openFrameworkDb();
118 XmlCursor cursor
= fdb
.getPackageList().newCursor();
119 cursor
.toFirstChild();
121 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
123 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
126 } while (cursor
.toNextSibling());
132 cursor
= fdb
.getPlatformList().newCursor();
133 cursor
.toFirstChild();
135 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
136 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
139 } while (cursor
.toNextSibling());
144 cursor
= fdb
.getFarList().newCursor();
145 cursor
.toFirstChild();
147 DbPathAndFilename item
= (DbPathAndFilename
) cursor
.getObject();
148 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
151 } while (cursor
.toNextSibling());
154 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
155 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
157 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
158 } catch (Exception e
) {
163 public String
getPackageFarGuid(Identification packageId
) {
166 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
167 DbPathAndFilename item
= fdb
.getPackageList().getFilenameArray(index
);
168 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
169 File tempFile
= new File(path
);
170 if (tempFile
.getPath().equalsIgnoreCase(packageId
.getPath())) {
171 return fdb
.getPackageList().getFilenameArray(index
).getFarGuid();
178 public String
getPlatformFarGuid(Identification platformId
) {
181 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
182 DbPathAndFilename item
= fdb
.getPlatformList().getFilenameArray(index
);
183 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
184 File tempFile
= new File(path
);
185 if (tempFile
.getPath().equalsIgnoreCase(platformId
.getPath())) {
186 return fdb
.getPlatformList().getFilenameArray(index
).getFarGuid();
193 public String
getModuleFarGuid(Identification moduleId
) {
194 PackageIdentification packageId
= getPackageIdByModuleId(moduleId
);
195 if (packageId
!= null) {
196 return getPackageFarGuid(packageId
);
203 Get all modules' paths from one package
205 @return a Vector with all modules' path
208 public Vector
<String
> getAllModulesOfPackage(String path
) {
209 Vector
<String
> modulePath
= new Vector
<String
>();
211 MsaFiles files
= OpenFile
.openSpdFile(path
).getMsaFiles();
213 for (int index
= 0; index
< files
.getFilenameList().size(); index
++) {
214 String msaPath
= files
.getFilenameList().get(index
);
215 msaPath
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + msaPath
;
216 msaPath
= Tools
.convertPathToCurrentOsType(msaPath
);
217 modulePath
.addElement(msaPath
);
220 } catch (IOException e
) {
222 } catch (XmlException e
) {
224 } catch (Exception e
) {
231 Get all Industry Std Includes' paths from one package
233 @return a Vector with all paths
236 public Vector
<String
> getAllIndustryStdIncludesOfPackage(String path
) {
237 Vector
<String
> includePath
= new Vector
<String
>();
239 IndustryStdIncludes files
= OpenFile
.openSpdFile(path
).getIndustryStdIncludes();
241 for (int index
= 0; index
< files
.getIndustryStdHeaderList().size(); index
++) {
242 String temp
= files
.getIndustryStdHeaderList().get(index
).getIncludeHeader();
243 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
244 temp
= Tools
.convertPathToCurrentOsType(temp
);
245 includePath
.addElement(temp
);
248 } catch (IOException e
) {
250 } catch (XmlException e
) {
252 } catch (Exception e
) {
259 Get all package basic information form the FrameworkDatabase.db file
261 @return vPackageList A vector includes all packages' basic information
264 public Vector
<PackageIdentification
> getAllPackages() {
265 Identification id
= null;
266 vPackageList
.removeAllElements();
270 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
271 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
272 + fdb
.getPackageList().getFilenameArray(index
).getStringValue();
273 path
= Tools
.convertPathToCurrentOsType(path
);
275 id
= getId(path
, OpenFile
.openSpdFile(path
));
276 vPackageList
.addElement(new PackageIdentification(id
));
277 } catch (IOException e
) {
278 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
280 } catch (XmlException e
) {
281 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
283 } catch (Exception e
) {
284 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
288 Tools
.sortPackages(vPackageList
, DataType
.SORT_TYPE_ASCENDING
);
292 public Vector
<FarIdentification
> getAllFars() {
294 Vector
<FarIdentification
> v
= new Vector
<FarIdentification
>();
295 for (int index
= 0; index
< fdb
.getFarList().getFilenameList().size(); index
++) {
296 DbPathAndFilename item
= fdb
.getFarList().getFilenameList().get(index
);
297 FarIdentification far
= new FarIdentification(item
.getFarGuid(), item
.getMd5Sum(), item
.getStringValue());
303 public Vector
<PackageIdentification
> getPackagesByFar(FarIdentification far
) {
304 Identification id
= null;
306 Vector
<PackageIdentification
> v
= new Vector
<PackageIdentification
>();
308 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
309 DbPathAndFilename item
= fdb
.getPackageList().getFilenameArray(index
);
310 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
311 path
= Tools
.convertPathToCurrentOsType(path
);
313 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
316 id
= getId(path
, OpenFile
.openSpdFile(path
));
317 v
.addElement(new PackageIdentification(id
));
318 } catch (IOException e
) {
319 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
321 } catch (XmlException e
) {
322 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
324 } catch (Exception e
) {
325 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
333 public Vector
<PlatformIdentification
> getPlatformsByFar(FarIdentification far
) {
334 Identification id
= null;
336 Vector
<PlatformIdentification
> v
= new Vector
<PlatformIdentification
>();
338 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
339 DbPathAndFilename item
= fdb
.getPlatformList().getFilenameArray(index
);
340 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ item
.getStringValue();
341 path
= Tools
.convertPathToCurrentOsType(path
);
343 if (item
.getFarGuid() != null && item
.getFarGuid().equalsIgnoreCase(far
.getGuid())) {
345 id
= getId(path
, OpenFile
.openFpdFile(path
));
346 v
.addElement(new PlatformIdentification(id
));
347 } catch (IOException e
) {
348 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
350 } catch (XmlException e
) {
351 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
353 } catch (Exception e
) {
354 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
363 Get all module basic information from a package
366 @return A vector includes all modules' basic information
369 public Vector
<ModuleIdentification
> getAllModules(PackageIdentification pid
) {
370 Vector
<ModuleIdentification
> v
= new Vector
<ModuleIdentification
>();
371 Vector
<String
> modulePaths
= this.getAllModulesOfPackage(pid
.getPath());
372 Identification id
= null;
373 String modulePath
= null;
375 for (int index
= 0; index
< modulePaths
.size(); index
++) {
377 modulePath
= modulePaths
.get(index
);
378 id
= getId(modulePath
, OpenFile
.openMsaFile(modulePath
));
379 } catch (IOException e
) {
380 Log
.log("Error when Open Module Surface Area " + modulePath
, e
.getMessage());
381 } catch (XmlException e
) {
382 Log
.log("Error when Open Module Surface Area " + modulePath
, e
.getMessage());
383 } catch (Exception e
) {
384 Log
.log("Error when Open Module Surface Area " + modulePath
, "Invalid file type " + e
.getMessage());
386 v
.addElement(new ModuleIdentification(id
, pid
));
388 Tools
.sortModules(v
, DataType
.SORT_TYPE_ASCENDING
);
394 Get all module basic information form the FrameworkDatabase.db file
396 @return vModuleList A vector includes all modules' basic information
399 public Vector
<ModuleIdentification
> getAllModules() {
400 vModuleList
.removeAllElements();
402 // First get all packages
405 Vector
<String
> modulePaths
= new Vector
<String
>();
406 Identification id
= null;
407 String packagePath
= null;
408 String modulePath
= null;
411 // For each package, get all modules list
413 for (int indexI
= 0; indexI
< vPackageList
.size(); indexI
++) {
414 packagePath
= vPackageList
.elementAt(indexI
).getPath();
415 modulePaths
= this.getAllModulesOfPackage(packagePath
);
417 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
419 modulePath
= modulePaths
.get(indexJ
);
420 id
= getId(modulePath
, OpenFile
.openMsaFile(modulePath
));
421 vModuleList
.addElement(new ModuleIdentification(id
, vPackageList
.elementAt(indexI
)));
422 } catch (IOException e
) {
423 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
424 } catch (XmlException e
) {
425 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
426 } catch (Exception e
) {
427 Log
.err("Open Module Surface Area " + modulePath
, "Invalid file type");
431 Tools
.sortModules(vModuleList
, DataType
.SORT_TYPE_ASCENDING
);
436 Get all platform basic information form the FrameworkDatabase.db file
438 @return vplatformList A vector includes all platforms' basic information
441 public Vector
<PlatformIdentification
> getAllPlatforms() {
442 Identification id
= null;
443 vPlatformList
.removeAllElements();
447 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
448 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
449 + fdb
.getPlatformList().getFilenameArray(index
).getStringValue();
450 path
= Tools
.convertPathToCurrentOsType(path
);
452 id
= getId(path
, OpenFile
.openFpdFile(path
));
453 vPlatformList
.addElement(new PlatformIdentification(id
));
454 } catch (IOException e
) {
455 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
456 } catch (XmlException e
) {
457 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
458 } catch (Exception e
) {
459 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
462 Tools
.sortPlatforms(vPlatformList
, DataType
.SORT_TYPE_ASCENDING
);
463 return vPlatformList
;
467 Get all Library Class Definitions from a package
471 public Vector
<String
> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd
) {
472 Vector
<String
> vector
= new Vector
<String
>();
473 if (spd
.getLibraryClassDeclarations() != null) {
474 if (spd
.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
475 for (int index
= 0; index
< spd
.getLibraryClassDeclarations().getLibraryClassList().size(); index
++) {
476 vector
.addElement(spd
.getLibraryClassDeclarations().getLibraryClassList().get(index
).getName());
480 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
485 Get all Protocol Definitions from a package
489 public Vector
<String
> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd
) {
490 Vector
<String
> vector
= new Vector
<String
>();
491 if (spd
.getProtocolDeclarations() != null) {
492 if (spd
.getProtocolDeclarations().getEntryList().size() > 0) {
493 for (int index
= 0; index
< spd
.getProtocolDeclarations().getEntryList().size(); index
++) {
494 vector
.addElement(spd
.getProtocolDeclarations().getEntryList().get(index
).getCName());
498 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
503 Get all Ppi Definitions from a package
507 public Vector
<String
> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd
) {
508 Vector
<String
> vector
= new Vector
<String
>();
509 if (spd
.getPpiDeclarations() != null) {
510 if (spd
.getPpiDeclarations().getEntryList().size() > 0) {
511 for (int index
= 0; index
< spd
.getPpiDeclarations().getEntryList().size(); index
++) {
512 vector
.addElement(spd
.getPpiDeclarations().getEntryList().get(index
).getCName());
516 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
521 Get all Guid Definitions from a package
525 public Vector
<String
> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd
) {
526 Vector
<String
> vector
= new Vector
<String
>();
527 if (spd
.getGuidDeclarations() != null) {
528 if (spd
.getGuidDeclarations().getEntryList().size() > 0) {
529 for (int index
= 0; index
< spd
.getGuidDeclarations().getEntryList().size(); index
++) {
530 vector
.addElement(spd
.getGuidDeclarations().getEntryList().get(index
).getCName());
534 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
539 Get all Pcd Definitions from a package
543 public PcdVector
getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd
) {
544 PcdVector vector
= new PcdVector();
545 if (spd
.getPcdDeclarations() != null) {
546 if (spd
.getPcdDeclarations().getPcdEntryList().size() > 0) {
547 for (int index
= 0; index
< spd
.getPcdDeclarations().getPcdEntryList().size(); index
++) {
548 String name
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getCName();
549 String guidCName
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getTokenSpaceGuidCName();
550 String help
= spd
.getPcdDeclarations().getPcdEntryList().get(index
).getHelpText();
551 Vector
<String
> type
= Tools
.convertListToVector(spd
.getPcdDeclarations().getPcdEntryList()
552 .get(index
).getValidUsage());
554 vector
.addPcd(new PcdIdentification(name
, guidCName
, help
, type
));
558 Tools
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
562 public Vector
<String
> getAllLibraryClassDefinitionsFromWorkspace() {
564 // First get all packages
566 this.getAllPackages();
568 Vector
<String
> vector
= new Vector
<String
>();
569 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
571 Vector
<String
> v
= getAllLibraryClassDefinitionsFromPackage(OpenFile
572 .openSpdFile(vPackageList
575 if (v
!= null && v
.size() > 0) {
578 } catch (IOException e
) {
579 // TODO Auto-generated catch block
580 } catch (XmlException e
) {
581 // TODO Auto-generated catch block
582 } catch (Exception e
) {
583 // TODO Auto-generated catch block
586 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
590 public Vector
<String
> getAllProtocolDeclarationsFromWorkspace() {
592 // First get all packages
594 this.getAllPackages();
596 Vector
<String
> vector
= new Vector
<String
>();
597 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
599 Vector
<String
> v
= getAllProtocolDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
)
601 if (v
!= null && v
.size() > 0) {
604 } catch (IOException e
) {
605 // TODO Auto-generated catch block
606 } catch (XmlException e
) {
607 // TODO Auto-generated catch block
608 } catch (Exception e
) {
609 // TODO Auto-generated catch block
612 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
616 public Vector
<String
> getAllPpiDeclarationsFromWorkspace() {
618 // First get all packages
620 this.getAllPackages();
622 Vector
<String
> vector
= new Vector
<String
>();
623 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
625 Vector
<String
> v
= getAllPpiDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
)
627 if (v
!= null && v
.size() > 0) {
630 } catch (IOException e
) {
631 // TODO Auto-generated catch block
632 } catch (XmlException e
) {
633 // TODO Auto-generated catch block
634 } catch (Exception e
) {
635 // TODO Auto-generated catch block
638 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
642 public Vector
<String
> getAllGuidDeclarationsFromWorkspace() {
644 // First get all packages
646 this.getAllPackages();
648 Vector
<String
> vector
= new Vector
<String
>();
649 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
651 Vector
<String
> v
= getAllGuidDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
)
653 if (v
!= null && v
.size() > 0) {
656 } catch (IOException e
) {
657 // TODO Auto-generated catch block
658 } catch (XmlException e
) {
659 // TODO Auto-generated catch block
660 } catch (Exception e
) {
661 // TODO Auto-generated catch block
664 Tools
.sortVectorString(vector
, DataType
.SORT_TYPE_ASCENDING
);
668 public PcdVector
getAllPcdDeclarationsFromWorkspace() {
670 // First get all packages
672 this.getAllPackages();
674 PcdVector vector
= new PcdVector();
675 for (int index
= 0; index
< this.vPackageList
.size(); index
++) {
677 PcdVector v
= getAllPcdDeclarationsFromPackage(OpenFile
.openSpdFile(vPackageList
.get(index
).getPath()));
678 if (v
!= null && v
.size() > 0) {
681 } catch (IOException e
) {
682 // TODO Auto-generated catch block
683 } catch (XmlException e
) {
684 // TODO Auto-generated catch block
685 } catch (Exception e
) {
686 // TODO Auto-generated catch block
689 Tools
.sortPcds(vector
, DataType
.SORT_TYPE_ASCENDING
);
694 Find a module's package's id
696 @param id input module id
700 public PackageIdentification
getPackageIdByModuleId(Identification id
) {
702 Vector
<String
> modulePaths
= new Vector
<String
>();
703 Identification mid
= null;
704 String packagePath
= null;
705 String modulePath
= null;
708 // For each package, get all modules list
710 for (int indexI
= 0; indexI
< vPackageList
.size(); indexI
++) {
711 packagePath
= vPackageList
.elementAt(indexI
).getPath();
712 modulePaths
= this.getAllModulesOfPackage(packagePath
);
713 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
714 modulePath
= modulePaths
.get(indexJ
);
716 mid
= getId(modulePath
, OpenFile
.openMsaFile(modulePath
));
720 if (mid
.equals(id
)) {
721 return vPackageList
.elementAt(indexI
);
723 } catch (IOException e
) {
725 } catch (XmlException e
) {
727 } catch (Exception e
) {
736 public Identification
getId(String path
, ModuleSurfaceArea msa
) {
737 MsaHeader head
= msa
.getMsaHeader();
738 String name
= head
.getModuleName();
739 String guid
= head
.getGuidValue();
740 String version
= head
.getVersion();
741 Identification id
= new Identification(name
, guid
, version
, path
);
745 public Identification
getId(String path
, PackageSurfaceArea spd
) {
746 SpdHeader head
= spd
.getSpdHeader();
747 String name
= head
.getPackageName();
748 String guid
= head
.getGuidValue();
749 String version
= head
.getVersion();
750 Identification id
= new Identification(name
, guid
, version
, path
);
754 public Identification
getId(String path
, PlatformSurfaceArea fpd
) {
755 PlatformHeader head
= fpd
.getPlatformHeader();
756 String name
= head
.getPlatformName();
757 String guid
= head
.getGuidValue();
758 String version
= head
.getVersion();
759 Identification id
= new Identification(name
, guid
, version
, path
);
764 Add module information to package surface area
772 public void addModuleToPackage(ModuleIdentification mid
, PackageSurfaceArea spd
) throws IOException
, XmlException
,
774 String packagePath
= mid
.getPackageId().getPath();
775 String modulePath
= mid
.getPath();
777 spd
= OpenFile
.openSpdFile(packagePath
);
779 MsaFiles msaFile
= spd
.getMsaFiles();
780 if (msaFile
== null) {
781 msaFile
= MsaFiles
.Factory
.newInstance();
783 packagePath
= packagePath
.substring(0, packagePath
.lastIndexOf(DataType
.FILE_SEPARATOR
));
784 String fn
= Tools
.getRelativePath(modulePath
, packagePath
);
785 msaFile
.addNewFilename();
786 msaFile
.setFilenameArray(msaFile
.getFilenameList().size() - 1, fn
);
787 spd
.setMsaFiles(msaFile
);
788 SaveFile
.saveSpdFile(mid
.getPackageId().getPath(), spd
);
792 Add input package into database
798 public void addPackageToDatabase(PackageIdentification id
) throws Exception
{
799 String path
= id
.getPath();
800 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
801 this.openFrameworkDb();
802 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
803 filename
.setStringValue(path
);
804 fdb
.getPackageList().addNewFilename();
805 fdb
.getPackageList().setFilenameArray(fdb
.getPackageList().sizeOfFilenameArray() - 1, filename
);
806 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
807 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
808 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
812 Add input package into database
818 public void addPlatformToDatabase(PlatformIdentification id
) throws Exception
{
819 String path
= id
.getPath();
820 path
= Tools
.getRelativePath(path
, Workspace
.getCurrentWorkspace());
821 this.openFrameworkDb();
822 DbPathAndFilename filename
= DbPathAndFilename
.Factory
.newInstance();
823 filename
.setStringValue(path
);
824 fdb
.getPlatformList().addNewFilename();
825 fdb
.getPlatformList().setFilenameArray(fdb
.getPlatformList().sizeOfFilenameArray() - 1, filename
);
826 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
827 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
828 SaveFile
.saveDbFile(strFrameworkDbFilePath
, fdb
);
832 Get all file's path from one module
841 public Vector
<String
> getAllModuleFilesPath(String path
) throws IOException
, XmlException
, Exception
{
842 Vector
<String
> v
= new Vector
<String
>();
843 path
= Tools
.convertPathToCurrentOsType(path
);
845 ModuleSurfaceArea msa
= OpenFile
.openMsaFile(path
);
848 // Get all files' path of a module
850 SourceFiles sf
= msa
.getSourceFiles();
852 for (int index
= 0; index
< sf
.getFilenameList().size(); index
++) {
853 String temp
= sf
.getFilenameList().get(index
).getStringValue();
854 temp
= Tools
.addFileSeparator(Tools
.getFilePathOnly(path
)) + temp
;
855 v
.addElement(Tools
.convertPathToCurrentOsType(temp
));
864 Get all file's path from one package
873 public Vector
<String
> getAllPakcageFilesPath(String path
) throws IOException
, XmlException
, Exception
{
874 Vector
<String
> v
= new Vector
<String
>();
875 path
= Tools
.convertPathToCurrentOsType(path
);
882 // Add the package's industry std includes one by one
884 Vector
<String
> f1
= new Vector
<String
>();
885 f1
= getAllIndustryStdIncludesOfPackage(path
);
886 for (int index
= 0; index
< f1
.size(); index
++) {
887 v
.addElement(f1
.get(index
));
891 // Add module's files one by one
893 f1
= new Vector
<String
>();
894 f1
= getAllModulesOfPackage(path
);
895 for (int indexI
= 0; indexI
< f1
.size(); indexI
++) {
896 Vector
<String
> f2
= getAllModuleFilesPath(f1
.get(indexI
));
897 for (int indexJ
= 0; indexJ
< f2
.size(); indexJ
++) {
898 v
.addElement(f2
.get(indexJ
));