14 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
33 import java.util.ArrayList;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.List;
38 import java.util.logging.Level;
39 import java.util.logging.Logger;
40 import javax.persistence.EntityManager;
41 import javax.persistence.EntityTransaction;
42 import javax.persistence.Query;
63 public static ArrayList<Suggestion>
persist(
RequestInfo requestInfo, ArrayList<Annotation> addedAnnotations, ArrayList<Annotation> editedAnnotations,
64 ArrayList<Suggestion> NERsuggestions,
boolean solveFeedbacks, ArrayList<AnnotType> addedTypes)
66 ArrayList<Annotation> requestAnnotations = null;
67 if (addedAnnotations != null || editedAnnotations != null) {
68 requestAnnotations =
new ArrayList<Annotation>();
69 if (addedAnnotations != null) {
70 requestAnnotations.addAll(addedAnnotations);
72 if (editedAnnotations != null) {
73 requestAnnotations.addAll(editedAnnotations);
77 EntityManager em = AppBean.getPersistenceManager().getEM();
78 EntityTransaction transaction = em.getTransaction();
79 boolean errorOccurred =
false;
80 ArrayList<Suggestion> touchedSuggestions =
new ArrayList<Suggestion>();
86 ArrayList<AnnotType> nTWA =
new ArrayList<AnnotType>();
87 Map<String, AnnotType> nTMap =
new HashMap<String, AnnotType>();
88 for (Iterator<AnnotType> ntIt = addedTypes.iterator(); ntIt.hasNext();) {
91 if (type.
getId() != null) {
95 nT.setRestrictedAtt(type.getRestrictedAtt());
96 nT.setUriInOntology(type.getUriInOntology());
97 nT.setComment(type.getComment());
99 nTMap.put(type.getUri(), type);
103 ArrayList<AnnotType> newCreatedTypes =
new ArrayList<AnnotType>();
104 ArrayList<AnnotType> mergedTypes =
new ArrayList<AnnotType>();
105 Map<String, AnnotType> mTypesMap =
new HashMap<String, AnnotType>();
106 for (Iterator<AnnotType> nTWAIt = nTWA.iterator(); nTWAIt.hasNext();) {
109 if (type.
getId() != null) {
112 type = em.merge(type);
113 mergedTypes.add(type);
114 mTypesMap.put(type.getUri(), type);
118 for (Iterator<AnnotType> mIt = mergedTypes.iterator(); mIt.hasNext();) {
120 AnnotType oType = nTMap.get(mType.getUri());
122 if (oType == null || mType == null){
126 List<AnnotTypeAttr> aList = oType.getAttributes();
127 for (Iterator<AnnotTypeAttr> aIt = aList.iterator(); aIt.hasNext();) {
129 AnnotType aTAAT = aTA.getAttributeType();
132 AnnotType rType = mTypesMap.get(aTAAT.getUri());
136 aTA.setAttributeType(rType);
139 aTA.setAnnotationType(mTypesMap.get(aTA.getAnnotationType().getUri()));
141 mType.setAttributes(
new ArrayList<AnnotTypeAttr>(aList));
144 if (oType.getAncestorType() != null) {
146 AnnotType rType = mTypesMap.get(oType.getAncestorType().getUri());
148 rType =
queryType(oType.getAncestorType().getUri(), em);
151 if (rType != null && rType.
getId() == null){
152 mType.setAncestorType(rType);
157 ArrayList<AnnotType> newAncestors =
new ArrayList<AnnotType>();
158 if (oType.getAncestorTypes() != null) {
159 for (Iterator<AnnotType> ancIt = oType.getAncestorTypes().iterator(); ancIt.hasNext();) {
161 AnnotType mAnc = mTypesMap.get(ancType.getUri());
166 if (mAnc != null && (ancType.
getId() != null || mAnc.getId() != null)) {
169 newAncestors.add(mAnc);
172 mType.setAncestorTypes(newAncestors);
174 mType = em.merge(mType);
175 newCreatedTypes.add(mType);
179 for (Iterator<AnnotType> it = addedTypes.iterator(); it.hasNext();) {
181 if (type.
getId() == null) {
185 addedTypes.addAll(newCreatedTypes);
189 ArrayList<Suggestion> suggestions =
new ArrayList<Suggestion>();
190 ArrayList<SuggestionLogEntry> confirmed = requestInfo.getConfirmedSuggestions();
191 ArrayList<Annotation> confirmedAnnotations =
new ArrayList<Annotation>();
194 HashMap<Annotation, Suggestion> anOldSugLinkMap =
new HashMap<Annotation, Suggestion>();
196 if (editedAnnotations != null) {
197 for (Iterator<Annotation> it = editedAnnotations.iterator(); it.hasNext();) {
199 Query query2 = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId IS NOT NULL");
200 query2.setParameter(1, an.getId());
201 List sList = query2.getResultList();
202 if (sList != null && !sList.isEmpty()) {
207 sugFeed.setAnnot(null);
210 anOldSugLinkMap.put(an, s);
211 if (!touchedSuggestions.contains(s)) {
212 touchedSuggestions.add(s);
218 if(requestAnnotations != null){
219 if(confirmed != null && !confirmed.isEmpty()){
220 Iterator<SuggestionLogEntry> logIt = confirmed.iterator();
221 while(logIt.hasNext()){
224 if(actualSuggestion != null){
226 actualSuggestion.setConfidence(0);
227 em.merge(actualSuggestion);
229 if (actualLogItem.
getConfirmedVersion() != null && actualLogItem.getConfirmedVersion().getAnnotType() != null && actualLogItem.getConfirmedVersion().getAnnotType().getGroup() != null) {
232 if (!touchedSuggestions.contains(actualSuggestion)) {
233 touchedSuggestions.add(actualSuggestion);
236 suggestions.add(actualSuggestion);
237 confirmedAnnotations.add(actualLogItem.getConfirmedVersion());
246 Iterator<Annotation> reqAnnotIt;
247 ArrayList<Annotation> nestedInReqAnnotations =
new ArrayList<Annotation>();
248 HashMap<Integer, Suggestion> reqSuggs =
new HashMap<Integer, Suggestion>();
251 HashMap<Annotation, Suggestion> anNewSugLinkMap =
new HashMap<Annotation, Suggestion>();
252 if(requestAnnotations != null){
253 reqAnnotIt = requestAnnotations.iterator();
254 while(reqAnnotIt.hasNext()){
256 if(!confirmedAnnotations.contains(annot)){
264 ArrayList<Suggestion> sugForStore =
new ArrayList<Suggestion>();
265 ArrayList<Suggestion> sugForActualization =
new ArrayList<Suggestion>();
266 if(requestAnnotations != null){
267 for (Iterator<Suggestion> it = suggestions.iterator(); it.hasNext();) {
269 if (sg.
getId() == null) {
272 sugForActualization.add(sg);
277 Iterator<Suggestion> sugListIt = NERsuggestions.iterator();
278 while(sugListIt.hasNext()){
282 if (sug.
getId() != null) {
283 Query query = em.createNamedQuery(
"Suggestion.findById");
284 query.setParameter(
"id", sug.getId());
285 sList = query.getResultList();
288 if (sList == null || sList.isEmpty()) {
290 sugForStore.add(sug);
293 sugForActualization.add(sug);
299 ArrayList<Suggestion> nowSavedSugs =
new ArrayList<Suggestion>();
300 ArrayList<Suggestion> justSavedSugs =
new ArrayList<Suggestion>();
301 Iterator<Suggestion> addedSugIter = sugForStore.iterator();
302 while (addedSugIter.hasNext()) {
308 updateTypes(sug, em,
"New type of suggestion was not found by Persister: ");
311 if (justSavedSugs.contains(sug)) {
320 if (NERsuggestions != null) {
321 NERsuggestions.clear();
323 for (Iterator<Suggestion> it = nowSavedSugs.iterator(); it.hasNext();) {
326 if (NERsuggestions != null) {
327 NERsuggestions.add(sg);
329 touchedSuggestions.add(sg);
332 Iterator<Suggestion> editSuggIter = sugForActualization.iterator();
333 while (editSuggIter.hasNext()) {
335 if (suggestion.
getAnnotType() == null || suggestion.getAnnotType().getId() == null) {
336 updateTypes(suggestion, em,
"New type of annotation for edited suggestion was not found by Persister: ");
338 if(requestAnnotations != null){
339 updateSugg(em, suggestion, requestInfo, touchedSuggestions, solveFeedbacks);
342 updateNerSugg(em, suggestion, touchedSuggestions, requestInfo);
344 if (!touchedSuggestions.contains(suggestion)) {
345 touchedSuggestions.add(suggestion);
347 if (NERsuggestions != null && !NERsuggestions.contains(suggestion)) {
348 NERsuggestions.add(suggestion);
354 if(requestAnnotations != null){
356 reqAnnotIt = requestAnnotations.iterator();
357 while(reqAnnotIt.hasNext()){
362 Iterator<Annotation> nestedInReqIt = nestedInReqAnnotations.iterator();
363 while(nestedInReqIt.hasNext()){
369 Iterator<Suggestion>addeSuggIter = sugForStore.iterator();
370 while(addeSuggIter.hasNext()){
375 Iterator<Suggestion>edSuggIter = sugForActualization.iterator();
376 while(edSuggIter.hasNext()){
382 Iterator oldSugIt = anOldSugLinkMap.entrySet().iterator();
384 while (oldSugIt.hasNext()) {
385 Map.Entry pair = (Map.Entry)oldSugIt.next();
387 if (anNewSugLinkMap.containsKey((
Annotation)pair.getKey())) {
393 Query query = em.createNamedQuery(
"SuggestionAttribute.findByLinked");
394 query.setParameter(
"linked", oldSug.getId());
396 @SuppressWarnings(
"unchecked")
397 List<SugBaseAttribute> attList = query.getResultList();
399 if (attList != null && !attList.isEmpty()) {
401 Iterator<SugBaseAttribute> sugListIt = attList.iterator();
402 while (sugListIt.hasNext()) {
406 sba = SugAttributeManager.changeAttributeInstance(sba);
411 SugLinkedAttribute sla = (SugLinkedAttribute) sba;
414 && oldSug.getURI() != null) {
416 sla.setValue(newSug);
420 String msg =
"Wrong attribute.";
421 Logger.getLogger(SuggestionManager.class.getName()).log(Level.SEVERE, msg);
431 transaction.commit();
432 }
catch (Exception e) {
433 transaction.rollback();
435 String msg =
"Exception during the persisting of data.";
436 Logger.getLogger(SugPersister.class.getName()).log(Level.SEVERE, msg, e);
438 errorOccurred =
true;
445 Object[] params =
new Object[2];
447 params[1] = requestInfo.getSession().getUser().getId();
448 List uList = AppBean.getPersistenceManager().queryDB(
"User.findById", params);
449 if (uList != null && !uList.isEmpty()) {
450 requestInfo.getSession().setUser((
User) uList.get(0));
451 requestInfo.getSession().actualizeAllCachedSettings();
455 return touchedSuggestions;
467 Query query = em.createNamedQuery(
"Suggestion.findById");
468 query.setParameter(
"id", sug.getId());
469 List sList = query.getResultList();
471 if (sList == null || sList.isEmpty()) {
478 List<SuggestionFragment> fragments = s.getFragments();
479 Iterator<SuggestionFragment> frIter = fragments.iterator();
480 Iterator<SuggestionFragment> newFrIter = sug.getFragments().iterator();
481 while (frIter.hasNext()) {
483 if (!newFrIter.hasNext()) {
487 newFr.setId(fr.getId());
492 List attrs = s.getAttributes();
493 Iterator attrsIt = attrs.iterator();
496 HashMap<Integer, Suggestion> nestedSugs =
new HashMap<Integer, Suggestion>();
498 while (attrsIt.hasNext()) {
501 nestedSugs.put(attr.getNestedSuggestion().getId(), attr.getNestedSuggestion());
530 ArrayList<Annotation> nestedInReqAnnotations, ArrayList<Suggestion> touchedSuggestions, HashMap<Annotation, Suggestion> anNewSugLinkMap)
533 Object[] params =
new Object[2];
535 params[1] = annot.getId();
536 Query q = em.createNamedQuery(
"SuggestionFeedback.findByAnnotNotNull");
537 for (
int p = 0; p < params.length; p = p + 2) {
538 q.setParameter((String) params[p], params[p + 1]);
540 List sList = q.getResultList();
541 if (sList == null || sList.isEmpty()) {
545 Iterator<SugBaseAttribute> newSugAttIt = newSug.getAttributes().iterator();
546 if (newSugAttIt != null) {
547 while (newSugAttIt.hasNext()) {
550 newSugAttIt.remove();
556 List<BaseAttribute> attrs = annot.getAttributes();
557 Iterator<BaseAttribute> attrsIt = attrs.iterator();
561 for (Iterator it = newSug.
getAttributes().iterator(); it.hasNext();) {
562 Object attribute = it.next();
570 ArrayList<Suggestion> toAddNestedIn =
new ArrayList<Suggestion>();
572 while(attrsIt.hasNext()){
574 if(attr.
getSimpleType().equalsIgnoreCase(
"NestedAnnotation")){
578 reqSuggs, nestedInReqAnnotations, touchedSuggestions, anNewSugLinkMap);
580 Boolean unknownError =
false;
583 nestedAttr = SugAttributeManager.createAttribute(attr.getName(),
"NestedSuggestion", newSug);
584 nestedAttr.updateFromBaseAttribut(attr);
586 catch(ClassNotFoundException ex){
593 nestedAttr.setNestedSuggestion(nested);
594 toAddNestedIn.add(nested);
595 newSug.addAttribute(nestedAttr);
601 SugBaseAttribute nestedAttr = SugAttributeManager.createAttribute(attr.getName(),
"NestedSuggestion", newSug);
602 nestedAttr.updateFromBaseAttribut(attr);
606 newSug.addAttribute(nestedAttr);
607 }
catch(ClassNotFoundException ex) {
609 String msg =
"Unknown type of attribute found.";
610 Logger.getLogger(SugPersister.class.getName()).log(Level.SEVERE, msg);
617 newSug = em.merge(newSug);
618 anNewSugLinkMap.put(annot, newSug);
622 for (Iterator<Suggestion> it = toAddNestedIn.iterator(); it.hasNext();) {
624 nested.setNestedInSuggestion(newSug);
629 if(!touchedSuggestions.contains(newSug)){
630 touchedSuggestions.add(newSug);
632 reqSuggs.put(annot.getId(), newSug);
646 HashMap<Integer, Suggestion> reqSuggs, EntityManager em, ArrayList<Suggestion> touchedSuggestions)
648 Iterator<BaseAttribute> attrsIt = annot.getAttributes().iterator();
649 while(attrsIt.hasNext()){
652 Suggestion lSug = reqSuggs.get(annot.getId());
657 }
catch (Exception e) {
659 String msg =
"Attempt to create unsupported type of attribute.";
660 Logger.getLogger(SugPersister.class.getName()).log(Level.SEVERE, msg);
664 linkedAttr.updateFromBaseAttribut(attr);
665 linkedAttr.setName(attr.getName());
666 lSug.addAttribute(linkedAttr);
668 if(laat.getValue() == null){
673 int linkedID = aVal.getId();
675 Query query = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId IS NOT NULL");
676 query.setParameter(1, linkedID);
677 List sList = query.getResultList();
678 if (sList != null && !sList.isEmpty()) {
680 Suggestion linkedSug = linkedSugFeed.getSuggestion();
681 linkedAttr.setValue(linkedSug);
683 if (!touchedSuggestions.contains(lSug)) {
684 touchedSuggestions.add(lSug);
687 }
catch (Exception e) {
689 String msg =
"Problem with database.";
690 Logger.getLogger(SugPersister.class.getName()).log(Level.SEVERE, msg);
695 Query query = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId IS NOT NULL");
696 query.setParameter(1, annot.getId());
697 List sList = query.getResultList();
698 if (sList != null && !sList.isEmpty()) {
700 lSug = lSugFeed.getSuggestion();
702 linkedAttr.updateFromBaseAttribut(attr);
703 lSug.addAttribute(linkedAttr);
706 if(laat.getValue() == null){
710 int linkedID = aVal.getId();
711 Query query2 = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId IS NOT NULL");
712 query2.setParameter(1, linkedID);
713 sList = query2.getResultList();
714 if (sList != null && !sList.isEmpty()) {
716 Suggestion linkedSug = linkedSugFeed.getSuggestion();
717 linkedAttr.setValue(linkedSug);
719 if (!touchedSuggestions.contains(lSug)) {
720 touchedSuggestions.add(lSug);
724 }
catch (Exception e) {
726 String msg =
"Problem with database.";
727 Logger.getLogger(SugPersister.class.getName()).log(Level.SEVERE, msg);
746 ArrayList<Suggestion> touchedSuggestions,
boolean solveFeedback)
throws RuntimeException
748 Integer setConfidence = null;
751 ArrayList<SuggestionLogEntry> confirmeSug = requestInfo.getConfirmedSuggestions();
752 if(confirmeSug != null){
753 Iterator<SuggestionLogEntry> confirmeSugIt = confirmeSug.iterator();
754 while(confirmeSugIt.hasNext()){
756 String tmpId = sugLog.getTmpId();
759 tmpIdInt = Integer.parseInt(tmpId);
761 catch(NumberFormatException ex){
764 if(tmpIdInt == suggestion.getId()){
765 actualEntry = sugLog;
784 if(sg != null && !touchedSuggestions.contains(sg)){
785 touchedSuggestions.add(sg);
788 if(setConfidence != null && solveFeedback){
789 suggestion.setConfidence(setConfidence);
791 em.merge(suggestion);
794 Annotation confirmedAnnot = actualEntry.getConfirmedVersion();
795 UserGroup userGroup = actualEntry.getConfirmedVersion().getAnnotType().getGroup();
799 if(!touchedSuggestions.contains(suggestion)){
800 touchedSuggestions.add(suggestion);
811 List attrList = sugg.getAttributes();
812 Iterator attrIt = attrList.iterator();
813 while(attrIt.hasNext()){
844 Object[] params =
new Object[2];
847 Query q = em.createNamedQuery(
"AnnotType.findByUri");
848 for (
int p = 0; p < params.length; p = p + 2) {
849 q.setParameter((String) params[p], params[p + 1]);
851 List aList = q.getResultList();
852 if (aList != null && !aList.isEmpty()) {
856 String msg =
"Queried type of annotation was not found by the Persister: " + uri;
857 Logger.getLogger(Persister.class.getName()).log(Level.SEVERE, msg);
859 throw new RuntimeException(
"New type not found!");
874 if (sug.getAnnotType() == null) {
876 String msg =
"The annotation has no type.";
877 Logger.getLogger(Persister.class.getName()).log(Level.SEVERE, msg);
882 Object[] params =
new Object[2];
884 params[1] = sug.getAnnotType().getUri();
885 Query q = em.createNamedQuery(
"AnnotType.findByUri");
886 for (
int p = 0; p < params.length; p = p + 2) {
887 q.setParameter((String) params[p], params[p + 1]);
889 List aList = q.getResultList();
890 if (aList != null && !aList.isEmpty()) {
892 sug.setAnnotType(annotType);
894 Iterator<SugBaseAttribute> attIt = sug.getAttributes().iterator();
895 while (attIt.hasNext()) {
903 params[1] = att.getAttributeType().getUri();
904 Query attTypeQuery = em.createNamedQuery(
"AnnotType.findByUri");
905 attTypeQuery.setParameter((String) params[0], params[1]);
907 List typeList = attTypeQuery.getResultList();
909 if (typeList != null && !typeList.isEmpty()) {
911 att.setAttributeType((
AnnotType)typeList.get(0));
917 String msg = logMsg + sug.getAnnotType().getUri();
918 Logger.getLogger(Persister.class.getName()).log(Level.SEVERE, msg);
920 throw new RuntimeException(
"New type not found!");
931 Iterator<SugBaseAttribute> aIt = sug.getAttributes().iterator();
932 while (aIt.hasNext()) {
934 Suggestion nested = attribute.getNestedSuggestion();
935 if (nested != null) {
936 if (nested.getAnnotType().getId() == null) {
939 nested.setAnnotType(annotType);
941 Iterator<SugBaseAttribute> attIt = sug.getAttributes().iterator();
942 while (attIt.hasNext()) {
950 Object[] params =
new Object[2];
952 params[1] = att.getAttributeType().getUri();
953 Query attTypeQuery = em.createNamedQuery(
"AnnotType.findByUri");
954 attTypeQuery.setParameter((String) params[0], params[1]);
956 List typeList = attTypeQuery.getResultList();
958 if (typeList != null && !typeList.isEmpty()) {
960 att.setAttributeType((
AnnotType)typeList.get(0));
995 List attrList = sug.getAttributes();
996 Iterator attrIt = attrList.iterator();
997 while(attrIt.hasNext()){
999 if((attr instanceof
SugLinkedAttribute) && ((SugLinkedAttribute)attr).getValue() != null){
1001 if (val.
getId() == null) {
1002 Iterator<Suggestion> nsIt = nowSaved.iterator();
1003 boolean found =
false;
1004 while (nsIt.hasNext()) {
1006 if (suggestion.
getTmpId() != null && suggestion.getTmpId().equals(val.
getTmpId())) {
1007 attr.setValue(suggestion);
1008 attr.setUri(suggestion.getURI());
1014 attr.setValue(annot4update);
1015 attr.setUri(annot4update.getURI());
1022 if (sug.getId() == null && sug.getNestedInSuggestion() == null) {
1023 updateTypes(sug, em,
"New type of suggestion for tmpId linked suggestion was not found by Persister: ");
1025 saved = em.merge(sug);
1027 saved.setTmpId(sug.getTmpId());
1028 if (justSaved != null) {
1031 if (nowSaved != null) {
1032 nowSaved.add(saved);
1049 feed.setAnnot(annot);
1050 if (annot != null) {
1051 feed.setAnnotationId(annot.getId());
1053 feed.setSuggestion(sugg);
1054 feed.setSuggestionId(sugg.getId());
1055 feed.setGroup(group);
1056 feed.setGroupId(group.getId());
1071 Query query = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId=?2 AND s.groupId=?3");
1072 query.setParameter(1, annot.getId());
1073 query.setParameter(2, oldSuggID);
1074 query.setParameter(3, group.getId());
1075 List sList = query.getResultList();
1076 if (sList != null && !sList.isEmpty()) {
1078 oldFeed.setAnnotationId(null);
1079 oldFeed.setAnnot(null);
1089 }
catch (Exception e) {
1091 String msg =
"Persisting of feedback failed.";
1092 Logger.getLogger(SugPersister.class.getName()).log(Level.SEVERE, msg, e);
1109 Query query = em.createNamedQuery(
"Suggestion.findById");
1110 query.setParameter(
"id", id);
1111 List sList = query.getResultList();
1112 if (sList == null || sList.isEmpty()) {
1130 Query query = em.createNamedQuery(
"SuggestionAttribute.findById");
1131 query.setParameter(
"id", id);
1132 List sList = query.getResultList();
1133 if (sList == null || sList.isEmpty()) {
1147 if (annot == null || annot.
getId() == null) {
1165 Query query2 = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId IS NOT NULL");
1166 query2.setParameter(1, annotId);
1167 List feedbackList = query2.getResultList();
1168 if(feedbackList != null && !feedbackList.isEmpty()){
1182 Query query = em.createQuery(
"SELECT s FROM Suggestion s WHERE s.id=?1");
1183 query.setParameter(1, id);
1184 List suggestionList = query.getResultList();
1185 if(suggestionList != null && !suggestionList.isEmpty()){
1201 for (Iterator<BaseAttribute> it = an.
getAttributes().iterator(); it.hasNext();) {
1204 Query query2 = em.createQuery(
"SELECT s FROM SuggestionFeedback s WHERE s.annotationId=?1 AND s.suggestionId IS NOT NULL");
1205 query2.setParameter(1, at.getNestedAnnotation().getId());
1206 List sList = query2.getResultList();
1207 if (sList != null && !sList.isEmpty()) {
1212 sugFeed.setAnnot(null);
1215 if (!touchedSuggestions.contains(s)) {
1216 touchedSuggestions.add(s);
1233 for (Iterator<SugBaseAttribute> it = sug.
getAttributes().iterator(); it.hasNext();) {
1240 if (!touchedSuggestions.contains(s)) {
1241 touchedSuggestions.add(s);
Static class which persists data to the database.
Annotation getNestedAnnotation()
Attribute manager provides a way how to create new attributes for prupose of suggestion.
static final int CONFIRMED_MANUALLY_EDITED
Class representing attribute of type of annotation.
static void setUriOfSuggParams(Suggestion sugg)
static AnnotType queryType(String uri, EntityManager em)
Annotation getConfirmedVersion()
Class representing attribute of type NestedAnnotation for peupose of suggestion.
Class representing attribute of type NestedAnnotation.
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
Singleton for storing global variables.
static final int CONFIRMED_AUTOMATICALLY_EDITED
static ArrayList< Suggestion > persist(RequestInfo requestInfo, ArrayList< Annotation > addedAnnotations, ArrayList< Annotation > editedAnnotations, ArrayList< Suggestion > NERsuggestions, boolean solveFeedbacks, ArrayList< AnnotType > addedTypes)
static SuggestionFeedback getFeedbackByAnnot(Integer annotId, EntityManager em)
static Suggestion saveTmpIdRefSuggestions(Suggestion sug, RequestInfo requestInfo, EntityManager em, ArrayList< Suggestion > justSaved, ArrayList< Suggestion > nowSaved)
static Suggestion getSuggestionByAnnotation(Annotation annot, EntityManager em)
static void updateTypes(Suggestion sug, EntityManager em, String logMsg)
Suggestion getNestedSuggestion()
ArrayList< UserGroup > getLeavedGroups()
Class representing attribute of type AnnotationLink.
static final int CONFIRMED_MANUALLY
Class representing attribute of suggestion.
static void updateTypesInNested(Suggestion sug, EntityManager em)
Class representing suggested annotation fragment.
Suggested annotation with informations about suggestion.
static Suggestion saveSuggestionsWithoutLinks(RequestInfo requestInfo, EntityManager em, Annotation annot, HashMap< Integer, Suggestion > reqSuggs, ArrayList< Annotation > nestedInReqAnnotations, ArrayList< Suggestion > touchedSuggestions, HashMap< Annotation, Suggestion > anNewSugLinkMap)
Class representing user group.
static boolean hasAttributeRightInstance(SugBaseAttribute attr)
static void changeFeedback(EntityManager em, Annotation annot, int oldSuggID, Suggestion newSugg, UserGroup group)
static Suggestion saveTmpIdRefSuggestions(Suggestion sug, RequestInfo requestInfo, EntityManager em)
static Suggestion getSuggestionFromDB(Integer id, EntityManager em)
AnnotType getAttributeType()
static void updateSugg(EntityManager em, Suggestion suggestion, RequestInfo requestInfo, ArrayList< Suggestion > touchedSuggestions, boolean solveFeedback)
static void createNewFeedback(EntityManager em, Annotation annot, Suggestion sugg, UserGroup group)
Static class which persists suggestion data to the database.
AnnotType getAttributeType()
ArrayList< UserGroup > getJoinedGroups()
Base class representing attribute of annotation.
static SugBaseAttribute getSugAttributeByID(Integer id, EntityManager em)
static final int LOG_LEVEL
static SugBaseAttribute createAttribute()
Class representing type of annotation.
Class representing attribute of type AnnotationLink for prupose of suggestion.
Integer getConfirmMethod()
static void updateLinksAndNested(Annotation annot, HashMap< Integer, Suggestion > reqSuggs, EntityManager em, ArrayList< Suggestion > touchedSuggestions)
List< SugBaseAttribute > getAttributes()
static Suggestion getSuggestionByID(Integer id, EntityManager em)
static final int LOG_LEVEL_SERVER_ERRORS
static void setNestedZeroConfidence(EntityManager em, Annotation an, ArrayList< Suggestion > touchedSuggestions)
Processed informations about client request.
Class representing suggestion of annotation.
Suggestion getLinkedSuggestion()
static final int CONFIRMED_CONFIDENCE
Represents database entitiy with suggestion feedback. feedback.
List< BaseAttribute > getAttributes()
Class representing annotation.
static void setNestedSugZeroConfidence(EntityManager em, Suggestion sug, ArrayList< Suggestion > touchedSuggestions)
static void updateNerSugg(EntityManager em, Suggestion sug, ArrayList< Suggestion > touchedSug, RequestInfo request)
Integer getSuggestionId()