Skip to main content
summaryrefslogtreecommitdiffstats
blob: dce0180ee7002dd2019e871d55b83c7889235336 (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
/*******************************************************************************
 * Copyright (c) 2013 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.disposition.rest.internal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.osee.disposition.model.Discrepancy;
import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoItem;
import org.eclipse.osee.disposition.model.DispoItemData;
import org.eclipse.osee.disposition.model.DispoSetData;
import org.eclipse.osee.disposition.model.DispoSetDescriptorData;
import org.eclipse.osee.disposition.model.DispoStrings;
import org.eclipse.osee.disposition.model.Note;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.logger.Log;

/**
 * @author Angel Avila
 */

public class DispoDataFactory {

   private Log logger;
   private DispoConnector dispoConnector;

   public void setLogger(Log logger) {
      this.logger = logger;
   }

   public void setDispoConnector(DispoConnector dispoConnector) {
      this.dispoConnector = dispoConnector;
   }

   public void start() {
      logger.trace("Starting DispoDataFactory...");
   }

   public void stop() {
      logger.trace("Stopping DispoDataFactory...");
   }

   public DispoSetData creteSetDataFromDescriptor(DispoSetDescriptorData descriptor) {
      DispoSetData newSet = new DispoSetData();
      newSet.setName(descriptor.getName());
      newSet.setImportPath(descriptor.getImportPath());
      newSet.setImportState("NONE");
      newSet.setNotesList(new ArrayList<Note>());
      newSet.setDispoType(descriptor.getDispoType());

      return newSet;
   }

   public void setStatus(DispoItemData item) {
      item.setStatus(dispoConnector.getItemStatus(item));
   }

   public void initDispoItem(DispoItemData itemToInit) {
      if (itemToInit.getAnnotationsList() == null) {
         itemToInit.setAnnotationsList(new ArrayList<DispoAnnotationData>());
      }
      if (itemToInit.getDiscrepanciesList() == null) {
         itemToInit.setDiscrepanciesList(new HashMap<String, Discrepancy>());
      }
      if (itemToInit.getDiscrepanciesList().size() == 0) {
         itemToInit.setStatus(DispoStrings.Item_Pass);
      } else {
         itemToInit.setStatus(dispoConnector.getItemStatus(itemToInit));
      }
      if (!Strings.isValid(itemToInit.getAssignee())) {
         itemToInit.setAssignee("UnAssigned");
      }

      itemToInit.setNeedsRerun(false);
      itemToInit.setNeedsReview(false);

   }

   public void initAnnotation(DispoAnnotationData annotationToInit) {
      annotationToInit.setIdsOfCoveredDiscrepancies(new ArrayList<String>());
      annotationToInit.setCustomerNotes("");
      annotationToInit.setDeveloperNotes("");
      annotationToInit.setResolution("");
      annotationToInit.setResolutionType("None");
      annotationToInit.setIsDefault(false);
   }

   public DispoItem createUpdatedItem(List<DispoAnnotationData> annotationsList, Map<String, Discrepancy> discrepanciesList) {
      DispoItemData newItem = new DispoItemData();
      newItem.setAnnotationsList(annotationsList);
      newItem.setDiscrepanciesList(discrepanciesList);
      newItem.setStatus(dispoConnector.getItemStatus(newItem));

      return newItem;
   }

   public String getNewId() {
      return GUID.create();
   }
}

Back to the top