summaryrefslogtreecommitdiffstats
path: root/src/com/ibm/ServerWizard2/model/Errata.java
blob: 30093abf543fe9fd1fe1ac9240f7b8e3c985d132 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.ibm.ServerWizard2.model;

import java.util.HashMap;
import java.util.Vector;

import org.eclipse.jface.dialogs.MessageDialog;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Errata {
	private String id = "";
	private String desc = "";
	private Boolean applied = false;
	private Vector<Attribute> attributes = new Vector<Attribute>();
	private String compareDetail = "";
	private Vector<Target> targets = new Vector<Target>();
	private String targetType = "";

	public Errata() {
		
	}
	public Errata(Errata e) {
		id = e.id;
		desc = e.desc;
		applied = e.applied;
		targetType = e.targetType;
		//don't deep copy attributes
		attributes = e.attributes;
	}
	public void addTarget(Target t) {
		targets.add(t);
	}
	public String getDetail() {
		return compareDetail;
	}
	public void setDetail(String d) {
		this.compareDetail = d;
	}
	public void setApplied(Boolean applied) {
		this.applied = applied;
	}
	public Boolean isApplied() { 
		return applied;
	}
	public String getTargetType() {
		return this.targetType;
	}
	public void updateAttributes() {
		for (Target t : targets) {
			for (Attribute a : attributes) {
				Attribute attrNew = new Attribute(a);
				t.getAttributes().put(attrNew.name,attrNew);
			}
		}
	}
	public void read(Element t, HashMap<String, Attribute> attributeModel) {
		attributes.removeAllElements();
		this.id = SystemModel.getElement(t, "errata_id");
		this.desc = SystemModel.getElement(t, "description");
		this.targetType = SystemModel.getElement(t, "target_type");
		NodeList attributeList = t.getElementsByTagName("attribute");
		for (int j = 0; j < attributeList.getLength(); ++j) {
			String attrId = SystemModel.getElement((Element) attributeList.item(j), "id");
			Attribute aModel = attributeModel.get(attrId);
			if (aModel == null) {
				MessageDialog.openError(null, "Error", "Invalid attribute " + attrId + " in Errata: " + id);
				return;
			} else {
				Attribute a = new Attribute(aModel);
				a.value.readInstanceXML((Element) attributeList.item(j));
				attributes.add(a);
			}
		}
	}
	public String getId() { 
		return id;
	}
	public String getDesc() {
		return desc;
	}
	public Vector<Attribute> getAttributes() {
		return attributes;
	}
	public void readInstance() {

	}
}
OpenPOWER on IntegriCloud