2 The file is used to provide initializing global data.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.common
;
15 import java
.io
.IOException
;
16 import java
.util
.Vector
;
18 import org
.apache
.xmlbeans
.XmlException
;
19 import org
.tianocore
.FrameworkDatabaseDocument
.FrameworkDatabase
;
20 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
21 import org
.tianocore
.MsaFilesDocument
.MsaFiles
;
22 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
23 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
24 import org
.tianocore
.frameworkwizard
.common
.Identifications
.Identification
;
25 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningModuleList
;
26 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPackageList
;
27 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPlatformList
;
28 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
29 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
30 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
31 import org
.tianocore
.frameworkwizard
.workspace
.Workspace
;
33 public class GlobalData
{
35 public static FrameworkDatabase fdb
= null;
37 public static OpeningModuleList openingModuleList
= new OpeningModuleList();
39 public static OpeningPackageList openingPackageList
= new OpeningPackageList();
41 public static OpeningPlatformList openingPlatformList
= new OpeningPlatformList();
43 public static Vector
<ModuleIdentification
> vModuleList
= new Vector
<ModuleIdentification
>();
45 public static Vector
<PackageIdentification
> vPackageList
= new Vector
<PackageIdentification
>();
47 public static Vector
<PlatformIdentification
> vPlatformList
= new Vector
<PlatformIdentification
>();
49 public static void init() {
56 public static void initDatabase() {
57 String strFrameworkDbFilePath
= Workspace
.getCurrentWorkspace() + Workspace
.getStrWorkspaceDatabaseFile();
58 strFrameworkDbFilePath
= Tools
.convertPathToCurrentOsType(strFrameworkDbFilePath
);
60 fdb
= OpenFile
.openFrameworkDb(strFrameworkDbFilePath
);
61 } catch (XmlException e
) {
62 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, e
.getMessage());
64 } catch (Exception e
) {
65 Log
.err("Open Framework Database " + strFrameworkDbFilePath
, "Invalid file type");
70 public static void initModule() {
71 vModuleList
= new Vector
<ModuleIdentification
>();
72 openingModuleList
= new OpeningModuleList();
74 ModuleSurfaceArea msa
= null;
75 Vector
<String
> modulePaths
= new Vector
<String
>();
76 Identification id
= null;
77 ModuleIdentification mid
= null;
78 String packagePath
= null;
79 String modulePath
= null;
82 // For each package, get all modules list
84 if (vPackageList
.size() > 0) {
85 for (int indexI
= 0; indexI
< vPackageList
.size(); indexI
++) {
86 packagePath
= vPackageList
.elementAt(indexI
).getPath();
87 modulePaths
= getAllModulesOfPackage(packagePath
);
89 for (int indexJ
= 0; indexJ
< modulePaths
.size(); indexJ
++) {
91 modulePath
= modulePaths
.get(indexJ
);
92 msa
= OpenFile
.openMsaFile(modulePath
);
94 } catch (IOException e
) {
95 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
96 } catch (XmlException e
) {
97 Log
.err("Open Module Surface Area " + modulePath
, e
.getMessage());
98 } catch (Exception e
) {
99 Log
.err("Open Module Surface Area " + modulePath
, "Invalid file type");
101 id
= Tools
.getId(modulePath
, msa
);
102 mid
= new ModuleIdentification(id
, vPackageList
.elementAt(indexI
));
103 vModuleList
.addElement(mid
);
104 openingModuleList
.insertToOpeningModuleList(mid
, msa
);
107 Sort
.sortModules(vModuleList
, DataType
.SORT_TYPE_ASCENDING
);
111 public static void initPackage() {
112 vPackageList
= new Vector
<PackageIdentification
>();
113 openingPackageList
= new OpeningPackageList();
115 for (int index
= 0; index
< fdb
.getPackageList().getFilenameList().size(); index
++) {
116 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
117 + fdb
.getPackageList().getFilenameArray(index
).getStringValue();
118 path
= Tools
.convertPathToCurrentOsType(path
);
119 PackageSurfaceArea spd
= null;
120 PackageIdentification id
= null;
122 spd
= OpenFile
.openSpdFile(path
);
123 } catch (IOException e
) {
124 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
125 } catch (XmlException e
) {
126 Log
.err("Open Package Surface Area " + path
, e
.getMessage());
127 } catch (Exception e
) {
128 Log
.err("Open Package Surface Area " + path
, "Invalid file type");
130 id
= Tools
.getId(path
, spd
);
131 vPackageList
.addElement(id
);
132 openingPackageList
.insertToOpeningPackageList(id
, spd
);
134 Sort
.sortPackages(vPackageList
, DataType
.SORT_TYPE_ASCENDING
);
138 public static void initPlatform() {
139 vPlatformList
= new Vector
<PlatformIdentification
>();
140 openingPlatformList
= new OpeningPlatformList();
143 for (int index
= 0; index
< fdb
.getPlatformList().getFilenameList().size(); index
++) {
144 String path
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
145 + fdb
.getPlatformList().getFilenameArray(index
).getStringValue();
146 path
= Tools
.convertPathToCurrentOsType(path
);
147 PlatformSurfaceArea fpd
= null;
148 PlatformIdentification id
= null;
150 fpd
= OpenFile
.openFpdFile(path
);
151 } catch (IOException e
) {
152 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
153 } catch (XmlException e
) {
154 Log
.err("Open Platform Surface Area " + path
, e
.getMessage());
155 } catch (Exception e
) {
156 Log
.err("Open Platform Surface Area " + path
, "Invalid file type");
158 id
= Tools
.getId(path
, fpd
);
159 vPlatformList
.addElement(new PlatformIdentification(id
));
160 openingPlatformList
.insertToOpeningPlatformList(id
, fpd
);
162 Sort
.sortPlatforms(vPlatformList
, DataType
.SORT_TYPE_ASCENDING
);
167 Get all modules' paths from one package
169 @return a Vector with all modules' path
172 private static Vector
<String
> getAllModulesOfPackage(String path
) {
173 Vector
<String
> modulePath
= new Vector
<String
>();
175 MsaFiles files
= OpenFile
.openSpdFile(path
).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
);
184 } catch (IOException e
) {
185 Log
.err("Get all modules from a package " + path
, e
.getMessage());
186 } catch (XmlException e
) {
187 Log
.err("Get all modules from a package " + path
, e
.getMessage());
188 } catch (Exception e
) {
189 Log
.err("Get all modules from a package " + path
, e
.getMessage());