blob: 4831ee38bca2e51ae4e92219e55679ada59add3d (
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
|
/*******************************************************************************
* Copyright (c) 2012 Boeing.
* 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:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ats.internal;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.event.filter.IEventFilter;
import org.eclipse.osee.framework.skynet.core.event.listener.IBranchEventListener;
import org.eclipse.osee.framework.skynet.core.event.model.BranchEvent;
import org.eclipse.osee.framework.skynet.core.event.model.BranchEventType;
import org.eclipse.osee.framework.skynet.core.event.model.Sender;
/**
* @author Donald G. Dunne
*/
public class AtsBranchManagerUpdateListener implements IBranchEventListener {
private static final List<BranchEventType> EVENT_TYPES = Arrays.asList(BranchEventType.Added,
BranchEventType.CommitFailed, BranchEventType.Committed, BranchEventType.Committing);
@Override
public List<? extends IEventFilter> getEventFilters() {
return null;
}
@Override
public void handleBranchEvent(Sender sender, BranchEvent branchEvent) {
if (!EVENT_TYPES.contains(branchEvent.getEventType())) {
return;
}
try {
Artifact assocArtInCache =
ArtifactCache.getActive(BranchManager.getAssociatedArtifactId(branchEvent.getSourceBranch()), COMMON);
if (assocArtInCache != null && assocArtInCache instanceof TeamWorkFlowArtifact) {
TeamWorkFlowArtifact teamArt = (TeamWorkFlowArtifact) assocArtInCache;
if (branchEvent.getEventType() == BranchEventType.Added) {
teamArt.setWorkingBranchCreationInProgress(false);
} else if (branchEvent.getEventType() == BranchEventType.Committing) {
teamArt.setWorkingBranchCommitInProgress(true);
} else if (branchEvent.getEventType() == BranchEventType.Committed || branchEvent.getEventType() == BranchEventType.CommitFailed) {
teamArt.setWorkingBranchCommitInProgress(false);
}
}
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
}
}
}
|