Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0c14040bed048b0cbb7c9d31ab03b9c1c039bb63 (plain) (blame)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*******************************************************************************
 * Copyright (c) 2011, 2017 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.director;

import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.query.IQueryable;

public class PlannerStatus implements IStatus {

	private final IStatus status;
	private final RequestStatus globalRequestStatus;
	private final Map<IInstallableUnit, RequestStatus> requestChanges;
	private final Map<IInstallableUnit, RequestStatus> requestSideEffects;
	private final IQueryable<IInstallableUnit> plannedState;

	private static final IQueryable<IInstallableUnit> EMPTY_IU_QUERYABLE = (query, monitor) -> Collector.emptyCollector();

	public PlannerStatus(IStatus status, RequestStatus globalRequestStatus, Map<IInstallableUnit, RequestStatus> requestChanges, Map<IInstallableUnit, RequestStatus> requestSideEffects, IQueryable<IInstallableUnit> plannedState) {
		this.status = status;
		this.globalRequestStatus = globalRequestStatus;
		this.requestChanges = requestChanges;
		this.requestSideEffects = requestSideEffects;
		this.plannedState = (plannedState == null) ? EMPTY_IU_QUERYABLE : plannedState;
	}

	/**
	 * Returns a request status object containing additional global details on the planning of the request
	 * 
	 * @return An IStatus object with global details on the planning process
	 */
	public RequestStatus getRequestStatus() {
		return globalRequestStatus;
	}

	/**
	 * Returns a map of the problems associated with changes to the given installable unit
	 * in this plan. A status with severity {@link IStatus#OK} is returned if the unit
	 * can be provisioned successfully
	 * 
	 * @return A map of {@link IInstallableUnit} to {@link IStatus} of the requested 
	 * changes and their corresponding explanation.
	 */
	public Map<IInstallableUnit, RequestStatus> getRequestChanges() {
		return requestChanges;
	}

	/**
	 * Returns a map of side-effects that will occur as a result of the plan being executed.
	 * Side-effects of an install may include:
	 * <ul>
	 * <li>Optional software being installed that will become satisfied once the plan
	 * is executed.</li>
	 * <li>Optional software currently in the profile that will be uninstalled as a result
	 * of the plan being executed. This occurs when the optional software has dependencies
	 * that are incompatible with the software being installed.
	 * This includes additional software that will be installed as a result of the change,
	 * or optional changes and their corresponding explanation.
	 * @return A map of {@link IInstallableUnit} to {@link IStatus} of the additional side effect
	 * status, or <code>null</code> if there are no side effects.
	 */
	public Map<IInstallableUnit, RequestStatus> getRequestSideEffects() {
		return requestSideEffects;
	}

	/**
	 * Returns the set of InstallableUnits that make up the expected planned state in terms 
	 * of additions and removals to the profile based on the planning process. 
	 * 
	 * @return An IQueryable of the InstallableUnits in the planned state. 
	 */
	public IQueryable<IInstallableUnit> getPlannedState() {
		return plannedState;
	}

	// Remaining Methods Delegate to wrapped Status 
	@Override
	public IStatus[] getChildren() {
		return status.getChildren();
	}

	@Override
	public int getCode() {
		return status.getCode();
	}

	@Override
	public Throwable getException() {
		return status.getException();
	}

	@Override
	public String getMessage() {
		return status.getMessage();
	}

	@Override
	public String getPlugin() {
		return status.getPlugin();
	}

	@Override
	public int getSeverity() {
		return status.getSeverity();
	}

	@Override
	public boolean isMultiStatus() {
		return status.isMultiStatus();
	}

	@Override
	public boolean isOK() {
		return status.isOK();
	}

	@Override
	public boolean matches(int severityMask) {
		return status.matches(severityMask);
	}

}

Back to the top