]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/DistributeRule.java
1. Support to Create/Update/Delete/Install far file
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / far / DistributeRule.java
1 /** @file
2
3 The file is used to distribute Far
4
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
10
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.
13
14 **/
15 package org.tianocore.frameworkwizard.far;
16
17 import java.util.ArrayList;
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Vector;
21
22 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
23 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
24
25 public class DistributeRule {
26 static PackageQuery pkgQ = new PackageQuery();
27
28 static WorkspaceTools wsTools = new WorkspaceTools();
29
30 static List<PackageIdentification> farPkgList = new ArrayList<PackageIdentification>();
31
32 public static List<PackageIdentification> installFarCheck(Far far) {
33
34 Far myFar = far;
35 List<PackageIdentification> pkgDepList = new ArrayList<PackageIdentification>();
36 List<PackageIdentification> dbPkgList = new ArrayList<PackageIdentification>();
37 List<PackageIdentification> depResultList = new ArrayList<PackageIdentification>();
38 //
39 // Get Far packages list;
40 //
41 try {
42 farPkgList = myFar.mainfest.getPackageList();
43 Iterator pkgItems = farPkgList.iterator();
44 while (pkgItems.hasNext()) {
45 PackageIdentification id = (PackageIdentification) pkgItems.next();
46 pkgDepList = myFar.getPackageDependencies(id);
47 depResultList = AggregationOperation.union(depResultList, pkgDepList);
48 }
49 dbPkgList = vectorToList(wsTools.getAllPackages());
50
51 } catch (Exception e) {
52 System.out.println(e.getMessage());
53 }
54
55 //
56 // Check does the dependence meet the requirement.
57 //
58 List<PackageIdentification> resultList = AggregationOperation.minus(depResultList,
59 AggregationOperation.union(farPkgList,
60 dbPkgList));
61
62 //
63 // If dependencies don't meet, print the error message and return.
64 //
65 // if (resultList != null || resultList.size()> 0){
66 // Iterator resItem = resultList.iterator();
67 // while (resItem.hasNext()){
68 // System.out.println("Missing package:" + resItem.next().toString() + " !");
69 // }
70 // }
71 return resultList;
72
73 }
74
75 // public void installPackgCheck (PackageIdentification pkgId, String pkgPath){
76 // List<PackageIdentification> dbPkgList = new ArrayList<PackageIdentification>();
77 // dbPkgList = vectorToList(wsTools.getAllPackages());
78 // //
79 // // Install far's package one by one.
80 // //
81 // if ((AggregationOperation.getExistItems(pkgId, dbPkgList))){
82 //
83 // }
84 // }
85
86 public void UpdatCheck(String orgFar, String destFar) {
87
88 }
89
90 public static List<PackageIdentification> vectorToList(Vector vec) {
91 List<PackageIdentification> set = new ArrayList<PackageIdentification>();
92 Iterator vecItem = vec.iterator();
93 while (vecItem.hasNext()) {
94 set.add((PackageIdentification) vecItem.next());
95 }
96 return set;
97 }
98
99 }