Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 16faeb4655c9b4d0c248816c9f889a1cc2bc09e7 (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
/*******************************************************************************
 * Copyright (c) 2013 Atos
 * 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:
 *     Arthur Daussy - initial implementation
 *******************************************************************************/
package org.eclipse.papyrus.team.collaborative.core.participants.version;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.papyrus.team.collaborative.core.Activator;
import org.eclipse.papyrus.team.collaborative.core.IExtendedURI;
import org.eclipse.papyrus.team.collaborative.core.participants.IExtendedURISuperSet;
import org.eclipse.papyrus.team.collaborative.core.reports.CollabStatus;


/**
 * Do an update action
 *
 * @author adaussy
 *
 *
 */
public interface IUpdater extends IExtendedURISuperSet {

	/** The Constant NOT_UP_TO_DATE. */
	public static final CollabStatus NOT_UP_TO_DATE = CollabStatus.createErrorStatus("Not up to Date");


	/**
	 * Update element of {@link IExtendedURISuperSet#getExtendedSet()}
	 *
	 * @return
	 * @throws CollabException
	 */
	IStatus update();

	/**
	 * Check if the elements has been modified
	 *
	 * @param uri
	 * @return
	 * @throws CollabException
	 */
	UpToDateStatus isUpToDate(IExtendedURI uri);

	public static class UpToDateStatus extends CollabStatus {

		protected String author;

		protected Long date;

		protected Long revision;

		private UpToDateStatus(int severity, String pluginId, int code, String message, Throwable exception, String author, Long date, Long revision) {
			super(severity, pluginId, code, message, exception);
			this.author = author;
			this.date = date;
			this.revision = revision;
		}

		public static int UP_TO_DATE_CODE = 578463;

		public static int NOT_UP_TO_DATE_CODE = 578463;

		public static int ERROR_DURING_OPERATION_CODE = 578462;

		public boolean isUpToDate() {
			return getSeverity() < IStatus.ERROR && getCode() == UP_TO_DATE_CODE;
		}

		public static UpToDateStatus createUpToDataStatus(String author, Long date, Long revision) {
			return new UpToDateStatus(IStatus.OK, Activator.PLUGIN_ID, UP_TO_DATE_CODE, "Is up to date", null, author, date, revision);
		}

		public static UpToDateStatus createNotUpToDataStatus(String author, Long date, Long revision) {
			return new UpToDateStatus(IStatus.ERROR, Activator.PLUGIN_ID, NOT_UP_TO_DATE_CODE, "Is noy up to date", null, author, date, revision);
		}

		public static UpToDateStatus createErrorDuringUpToDataStatus(String message, Throwable e) {
			return new UpToDateStatus(IStatus.ERROR, Activator.PLUGIN_ID, ERROR_DURING_OPERATION_CODE, message, e, null, null, null);
		}


		public static UpToDateStatus createErrorDuringUpToDataStatus(String message) {
			return createErrorDuringUpToDataStatus(message, null);
		}




	}



}

Back to the top