diff options
author | donald.g.dunne | 2017-01-25 21:57:14 +0000 |
---|---|---|
committer | David W. Miller | 2017-01-25 21:57:14 +0000 |
commit | 3d66f39802c8bf4557d4db95233f904cd0efe17b (patch) | |
tree | 4845c516288d53f151ee771eca350f51f5ba9560 /plugins/org.eclipse.osee.ats.core.client | |
parent | 653ab585ee4cee2f34bb9fcfed15ba15a65b3c63 (diff) | |
download | org.eclipse.osee-3d66f39802c8bf4557d4db95233f904cd0efe17b.tar.gz org.eclipse.osee-3d66f39802c8bf4557d4db95233f904cd0efe17b.tar.xz org.eclipse.osee-3d66f39802c8bf4557d4db95233f904cd0efe17b.zip |
refactor: Move AtsNotes to ats.core and services
Change-Id: Ibe5e6ac8f09cf2b6e0e388a63fd2b023754acadb
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core.client')
7 files changed, 2 insertions, 472 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF index 8481f5d1a62..5eea65dbeb6 100644 --- a/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF @@ -97,7 +97,6 @@ Export-Package: org.eclipse.osee.ats.core.client, org.eclipse.osee.ats.core.client.util, org.eclipse.osee.ats.core.client.validator, org.eclipse.osee.ats.core.client.workflow, - org.eclipse.osee.ats.core.client.workflow.note, org.eclipse.osee.ats.core.client.workflow.stateitem, org.eclipse.osee.ats.core.client.workflow.transition Bundle-Vendor: Eclipse Open System Engineering Environment diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java index 27015e8d163..c1cf3c07763 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java @@ -36,6 +36,7 @@ import org.eclipse.osee.ats.api.workflow.IAtsGoal; import org.eclipse.osee.ats.api.workflow.log.IAtsLog; import org.eclipse.osee.ats.api.workflow.log.IAtsLogItem; import org.eclipse.osee.ats.api.workflow.log.LogType; +import org.eclipse.osee.ats.api.workflow.note.IAtsWorkItemNotes; import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager; import org.eclipse.osee.ats.core.client.action.ActionArtifact; import org.eclipse.osee.ats.core.client.artifact.AbstractAtsArtifact; @@ -45,8 +46,6 @@ import org.eclipse.osee.ats.core.client.review.AbstractReviewArtifact; import org.eclipse.osee.ats.core.client.review.ReviewManager; import org.eclipse.osee.ats.core.client.task.TaskArtifact; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; -import org.eclipse.osee.ats.core.client.workflow.note.ArtifactNote; -import org.eclipse.osee.ats.core.client.workflow.note.AtsNote; import org.eclipse.osee.ats.core.users.AtsCoreUsers; import org.eclipse.osee.ats.core.util.AtsObjects; import org.eclipse.osee.ats.core.util.AtsUtilCore; @@ -89,7 +88,7 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple private IAtsLog atsLog; private TransactionId atsLogTx; private TransactionId stateMgrTransactionNumber; - private AtsNote atsNote; + private IAtsWorkItemNotes atsNote; private IAtsStateManager stateMgr; public AbstractWorkflowArtifact(String guid, BranchId branch, ArtifactTypeId artifactType) { @@ -412,13 +411,6 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple return atsLog; } - public AtsNote getNotes() { - if (atsNote == null) { - atsNote = new AtsNote(new ArtifactNote(this)); - } - return atsNote; - } - public Result getUserInputNeeded() { return Result.FalseResult; } diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/ArtifactNote.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/ArtifactNote.java deleted file mode 100644 index 82db8a3789f..00000000000 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/ArtifactNote.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.core.client.workflow.note; - -import java.lang.ref.WeakReference; -import java.util.logging.Level; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.osee.ats.api.data.AtsAttributeTypes; -import org.eclipse.osee.ats.core.client.internal.Activator; -import org.eclipse.osee.ats.core.client.util.AtsUtilClient; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.type.OseeStateException; -import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; - -/** - * @author Donald G. Dunne - */ -public class ArtifactNote implements INoteStorageProvider { - private final WeakReference<Artifact> artifactRef; - - public ArtifactNote(Artifact artifact) { - this.artifactRef = new WeakReference<>(artifact); - } - - @Override - public String getNoteXml() { - try { - return getArtifact().getSoleAttributeValue(AtsAttributeTypes.StateNotes, ""); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - return "getLogXml exception " + ex.getLocalizedMessage(); - } - } - - @Override - public IStatus saveNoteXml(String xml) { - try { - getArtifact().setSoleAttributeValue(AtsAttributeTypes.StateNotes, xml); - return Status.OK_STATUS; - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "saveLogXml exception " + ex.getLocalizedMessage()); - } - } - - public Artifact getArtifact() throws OseeStateException { - if (artifactRef.get() == null) { - throw new OseeStateException("Artifact has been garbage collected"); - } - return artifactRef.get(); - } - - @Override - public String getNoteTitle() { - try { - return "History for \"" + getArtifact().getArtifactTypeName() + "\" - " + getNoteId() + " - titled \"" + getArtifact().getName() + "\""; - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - return "getLogTitle exception " + ex.getLocalizedMessage(); - } - } - - @Override - public String getNoteId() { - try { - return AtsUtilClient.getAtsId(getArtifact()); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return "unknown"; - } - - @Override - public boolean isNoteable() { - try { - return getArtifact().isAttributeTypeValid(AtsAttributeTypes.StateNotes); - } catch (OseeCoreException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - return false; - } - -} diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/AtsNote.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/AtsNote.java deleted file mode 100644 index 5e7998a5725..00000000000 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/AtsNote.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.core.client.workflow.note; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import org.eclipse.osee.ats.api.user.IAtsUser; -import org.eclipse.osee.ats.core.client.internal.Activator; -import org.eclipse.osee.framework.jdk.core.util.AHTML; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.logging.OseeLevel; -import org.eclipse.osee.framework.logging.OseeLog; - -/** - * @author Donald G. Dunne - */ -public class AtsNote { - private boolean enabled = true; - private final INoteStorageProvider storeProvder; - - public AtsNote(INoteStorageProvider storeProvder) { - this.storeProvder = storeProvder; - } - - public void addNote(NoteType type, String state, String msg, IAtsUser user) { - addNote(type, state, msg, new Date(), user); - } - - public void addNoteItem(NoteItem noteItem) { - addNote(noteItem.getType(), noteItem.getState(), noteItem.getMsg(), noteItem.getDate(), noteItem.getUser()); - } - - public void addNote(NoteType type, String state, String msg, Date date, IAtsUser user) { - if (!enabled) { - return; - } - NoteItem logItem = new NoteItem(type, state, String.valueOf(date.getTime()), user, msg); - List<NoteItem> logItems = getNoteItems(); - if (logItems.isEmpty()) { - logItems = Arrays.asList(logItem); - } else { - logItems.add(logItem); - } - saveNoteItems(logItems); - } - - public List<NoteItem> getNoteItems() { - try { - String xml = storeProvder.getNoteXml(); - if (Strings.isValid(xml)) { - return NoteItem.fromXml(xml, storeProvder.getNoteId()); - } - } catch (Exception ex) { - OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); - } - return Collections.emptyList(); - } - - public void saveNoteItems(List<NoteItem> items) { - try { - String xml = NoteItem.toXml(items); - storeProvder.saveNoteXml(xml); - } catch (Exception ex) { - OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Can't create ats note document", ex); - } - } - - /** - * Display Note Table; If state == null, only display non-state notes Otherwise, show only notes associated with - * state - */ - public String getTable(String state) { - if (!storeProvder.isNoteable()) { - return ""; - } - ArrayList<NoteItem> showNotes = new ArrayList<>(); - List<NoteItem> noteItems = getNoteItems(); - - for (NoteItem li : noteItems) { - if (state == null && li.getState().equals("")) { - showNotes.add(li); - } else if (state != null && ("ALL".equals(state) || li.getState().equals(state))) { - showNotes.add(li); - } - } - if (showNotes.isEmpty()) { - return ""; - } - return buildTable(showNotes); - } - - private String buildTable(List<NoteItem> showNotes) { - StringBuilder builder = new StringBuilder(); - builder.append(AHTML.beginMultiColumnTable(100, 1)); - builder.append(AHTML.addHeaderRowMultiColumnTable(Arrays.asList("Type", "State", "Message", "User", "Date"))); - DateFormat dateFormat = getDateFormat(); - for (NoteItem note : showNotes) { - IAtsUser user = note.getUser(); - String name = ""; - if (user != null) { - name = user.getName(); - if (!Strings.isValid(name)) { - name = user.getName(); - } - } - builder.append(AHTML.addRowMultiColumnTable(String.valueOf(note.getType()), - note.getState().isEmpty() ? "," : note.getState(), note.getMsg().equals("") ? "," : note.getMsg(), name, - dateFormat.format(note.getDate()))); - } - builder.append(AHTML.endMultiColumnTable()); - return builder.toString(); - } - - public DateFormat getDateFormat() { - return new SimpleDateFormat("MM/dd/yyyy h:mm a", Locale.US); - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/INoteStorageProvider.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/INoteStorageProvider.java deleted file mode 100644 index fade839d9ea..00000000000 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/INoteStorageProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.core.client.workflow.note; - -import org.eclipse.core.runtime.IStatus; - -/** - * @author Donald G. Dunne - */ -public interface INoteStorageProvider { - - String getNoteXml(); - - IStatus saveNoteXml(String xml); - - String getNoteTitle(); - - String getNoteId(); - - boolean isNoteable(); -} diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/NoteItem.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/NoteItem.java deleted file mode 100644 index e70150fff9c..00000000000 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/NoteItem.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.core.client.workflow.note; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.logging.Level; -import org.eclipse.osee.ats.api.user.IAtsUser; -import org.eclipse.osee.ats.core.client.internal.Activator; -import org.eclipse.osee.ats.core.client.internal.AtsClientService; -import org.eclipse.osee.ats.core.users.AtsCoreUsers; -import org.eclipse.osee.framework.core.exception.UserNotInDatabase; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.util.DateUtil; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp; -import org.eclipse.osee.framework.logging.OseeLevel; -import org.eclipse.osee.framework.logging.OseeLog; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -/** - * @author Donald G. Dunne - */ -public class NoteItem { - - private Date date; - private final String state; - private String msg; - private IAtsUser user; - private NoteType type = NoteType.Other; - protected final static String LOG_ITEM_TAG = "Item"; - private final static String ATS_NOTE_TAG = "AtsNote"; - - public NoteItem(NoteType type, String state, String date, IAtsUser user, String msg) { - Long l = Long.valueOf(date); - this.date = new Date(l.longValue()); - this.state = Strings.intern(state); - this.msg = msg; - this.user = user; - this.type = type; - } - - public NoteItem(String type, String state, String date, IAtsUser user, String msg) throws OseeCoreException { - this(NoteType.getType(type), state, date, user, msg); - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - @Override - public String toString() { - return String.format("Note: %s from %s%s on %s - %s", type, user.getName(), toStringState(), - DateUtil.getMMDDYYHHMM(date), msg); - } - - private String toStringState() { - return state.isEmpty() ? "" : " for \"" + state + "\""; - } - - public IAtsUser getUser() { - return user; - } - - public NoteType getType() { - return type; - } - - public void setType(NoteType type) { - this.type = type; - } - - public String toHTML() { - return toString().replaceFirst("^Note: ", "<b>Note:</b>"); - } - - public String getState() { - return state; - } - - public void setUser(IAtsUser user) { - this.user = user; - } - - public static List<NoteItem> fromXml(String xml, String atsId) { - List<NoteItem> logItems = new ArrayList<>(); - try { - if (Strings.isValid(xml)) { - NodeList nodes = Jaxp.readXmlDocument(xml).getElementsByTagName(LOG_ITEM_TAG); - for (int i = 0; i < nodes.getLength(); i++) { - Element element = (Element) nodes.item(i); - try { - IAtsUser user = AtsClientService.get().getUserService().getUserById(element.getAttribute("userId")); - NoteItem item = new NoteItem(element.getAttribute("type"), element.getAttribute("state"), // NOPMD by b0727536 on 9/29/10 8:52 AM - element.getAttribute("date"), user, element.getAttribute("msg")); - logItems.add(item); - } catch (UserNotInDatabase ex) { - OseeLog.logf(Activator.class, Level.SEVERE, ex, "Error parsing notes for [%s]", atsId); - NoteItem item = new NoteItem(element.getAttribute("type"), element.getAttribute("state"), // NOPMD by b0727536 on 9/29/10 8:52 AM - element.getAttribute("date"), AtsCoreUsers.ANONYMOUS_USER, element.getAttribute("msg")); - logItems.add(item); - } - } - } - } catch (Exception ex) { - OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); - } - return logItems; - } - - public static String toXml(List<NoteItem> items) { - try { - Document doc = Jaxp.newDocumentNamespaceAware(); - Element rootElement = doc.createElement(ATS_NOTE_TAG); - doc.appendChild(rootElement); - for (NoteItem item : items) { - Element element = doc.createElement(NoteItem.LOG_ITEM_TAG); - element.setAttribute("type", item.getType().name()); - element.setAttribute("state", item.getState()); - element.setAttribute("date", String.valueOf(item.getDate().getTime())); - element.setAttribute("userId", item.getUser().getUserId()); - element.setAttribute("msg", item.getMsg()); - rootElement.appendChild(element); - } - return Jaxp.getDocumentXml(doc); - } catch (Exception ex) { - OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Can't create ats note document", ex); - } - return null; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/NoteType.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/NoteType.java deleted file mode 100644 index 478e2a55d2b..00000000000 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/note/NoteType.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.core.client.workflow.note; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; - -/** - * @author Donald G. Dunne - */ -public enum NoteType { - Comment, - Question, - Error, - Other; - - public static NoteType getType(String type) throws OseeArgumentException { - for (NoteType e : NoteType.values()) { - if (e.name().equals(type)) { - return e; - } - } - throw new OseeArgumentException("Unhandled NoteType"); - } - - public static List<String> getNames() { - List<String> names = new ArrayList<>(); - for (NoteType e : NoteType.values()) { - names.add(e.name()); - } - return names; - } - -}; |