Exemplo n.º 1
0
  private void modifyCurationToken(final MAnnotation annotation, String status) {
    MAnnotationSet set =
        _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(annotation.getLocalId());

    // Check if there is already a curation token
    MAnnotation alreadyExisting = null;
    for (MAnnotation token : annotation.getAnnotatedBy()) {
      if (token instanceof MCurationToken
          && token
              .getCreator()
              .getUri()
              .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
        alreadyExisting = token;
      }
    }
    if (alreadyExisting != null) {
      annotation.getAnnotatedBy().remove(alreadyExisting);
      _domeo.getPersistenceManager().removeAnnotation(alreadyExisting);
    }

    MCurationToken ann =
        CurationFactory.createCurationToken(
            _domeo,
            _domeo.getAgentManager().getUserPerson(),
            _domeo.getAgentManager().getSoftware(),
            annotation,
            status,
            "");

    _domeo
        .getAnnotationPersistenceManager()
        .addAnnotationOfAnnotation(
            ann, annotation, _domeo.getAnnotationPersistenceManager().getCurrentSet());
    _domeo.refreshAnnotationComponents();
  }
Exemplo n.º 2
0
 /** The abstract search on the text match is case sensitive. */
 @Override
 public boolean filterByText(MAnnotation annotation, String textSearch) {
   // TODO take into account multiple selectors
   if (SelectorUtils.isOnTextFragment(annotation.getSelectors())
       && annotation.getSelector() instanceof MTextSelector) {
     return (((MTextSelector) annotation.getSelector()).getExact().contains(textSearch));
   }
   return false;
 }
 public List<MAnnotation> search(IDomeo domeo, String accessFilter, String textSearch) {
   // System.out.println("3**|textSearch:" + textSearch);
   List<MAnnotation> found = new ArrayList<MAnnotation>();
   for (MAnnotation annotation : domeo.getAnnotationPersistenceManager().getAllAnnotations()) {
     ISearchComponent sc =
         domeo
             .getAnnotationSearchManager()
             .getAnnotationSearchComponent(domeo, annotation.getClass().getName());
     if (sc.filterByAccess(annotation, accessFilter)) {
       if (sc.filterByText(annotation, textSearch)) found.add(annotation);
     }
   }
   return found;
 }
Exemplo n.º 4
0
 @Override
 public boolean filterByAccess(MAnnotation annotation, String creatorFilter) {
   if (creatorFilter.equals(ANYBODY)) {
     return true;
   } else if (creatorFilter.equals(ONLY_MINE)
       && annotation
           .getCreator()
           .getUri()
           .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
     return true;
   } else if (creatorFilter.equals(ONLY_OTHERS)
       && !annotation
           .getCreator()
           .getUri()
           .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
     return true;
   }
   return false;
 }
Exemplo n.º 5
0
 private Map<String, Integer> countCurationToken(final MAnnotation annotation) {
   Map<String, Integer> tokens = new HashMap<String, Integer>();
   for (MAnnotation token : annotation.getAnnotatedBy()) {
     if (token instanceof MCurationToken
         && !token
             .getCreator()
             .getUri()
             .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
       String status = ((MCurationToken) token).getStatus();
       if (tokens.containsKey(status)) {
         Integer count = tokens.get(status);
         count++;
         tokens.put(status, count);
       } else {
         tokens.put(status, 1);
       }
     }
   }
   return tokens;
 }
  public List<MAnnotation> search(
      IDomeo domeo, String accessFilter, Long setLocalId, String typeFilter, String textSearch) {
    // System.out.println("1**|textSearch:" + textSearch);
    List<MAnnotation> found = new ArrayList<MAnnotation>();
    for (MAnnotation annotation : domeo.getAnnotationPersistenceManager().getAllAnnotations()) {
      ISearchComponent sc =
          domeo
              .getAnnotationSearchManager()
              .getAnnotationSearchComponent(domeo, annotation.getClass().getName());

      // System.out.println("0 |annotation name:" + annotation.getClass().getName());
      if (sc.filterBySet(annotation, setLocalId)) {
        // System.out.println("0 | 1");
        if (sc.filterByType(annotation, typeFilter)) {
          // System.out.println("0 | 2");
          if (sc.filterByAccess(annotation, accessFilter)) {
            // System.out.println("0 | 3");
            if (sc.filterByText(annotation, textSearch)) found.add(annotation);
          }
        }
      }
    }
    return found;
  }
Exemplo n.º 7
0
 @Override
 public boolean filterByType(MAnnotation annotation, String typeFilter) {
   if (typeFilter.equals("All types")) return true;
   return annotation.getClass().getName().equals(typeFilter);
 }
Exemplo n.º 8
0
  public void createProvenanceBar(
      String plugin, HorizontalPanel provenance, final MAnnotation annotation) {
    try {
      Resources resource = Domeo.resources;

      Image commentIcon = null;
      if (((BooleanPreference)
              _domeo
                  .getPreferences()
                  .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
          .getValue()) {
        commentIcon = new Image(resource.littleCommentIcon());
        commentIcon.setTitle("Comment on Item");
        commentIcon.setStyleName(ATileComponent.tileResources.css().button());
        commentIcon.addClickHandler(
            ActionCommentAnnotation.getClickHandler(_domeo, this, annotation));
        commentIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });
      }

      Image editIcon = new Image(resource.editLittleIcon());
      editIcon.setTitle("Edit Item");
      if (_domeo.getProfileManager().getUserCurrentProfile().isPluginEnabled(plugin)) {
        editIcon.setStyleName(ATileComponent.tileResources.css().button());
        editIcon.addClickHandler(ActionEditAnnotation.getClickHandler(_domeo, this, annotation));
        editIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });
      }

      Image deleteIcon = new Image(resource.deleteLittleIcon());
      deleteIcon.setTitle("Delete Item");
      deleteIcon.setStyleName(ATileComponent.tileResources.css().button());
      deleteIcon.addClickHandler(ActionDeleteAnnotation.getClickHandler(_domeo, this, annotation));
      deleteIcon.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              _curationPopup.hide();
            }
          });

      // TODO move to an abstract tile class
      if (((BooleanPreference)
              _domeo
                  .getPreferences()
                  .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_DISPLAY_PROVENANCE))
          .getValue()) {
        if (annotation
            .getCreator()
            .getUri()
            .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
          if (((BooleanPreference)
                  _domeo
                      .getPreferences()
                      .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_DISPLAY_USER_PROVENANCE))
              .getValue()) {
            provenance.clear();

            // TODO Externalize the icon management to the plugins
            if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
              Image ic = new Image(Domeo.resources.multipleLittleIcon());
              ic.setTitle("Annotation on multiple targets");
              provenance.add(ic);
              provenance.setCellWidth(ic, "18px");
            } else if (annotation.getSelector() != null
                && annotation.getSelector().getTarget() instanceof MOnlineImage) {
              Image ic = new Image(Domeo.resources.littleImageIcon());
              ic.setTitle("Annotation on image");
              provenance.add(ic);
              provenance.setCellWidth(ic, "18px");
            } else {
              Image ic = new Image(Domeo.resources.littleTextIcon());
              ic.setTitle("Annotation on text");
              provenance.add(ic);
              provenance.setCellWidth(ic, "18px");
            }

            provenance.add(new Label("By Me on " + annotation.getFormattedCreationDate()));

            if (((BooleanPreference)
                    _domeo
                        .getPreferences()
                        .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
                .getValue()) {
              provenance.add(commentIcon);
              provenance.setCellWidth(commentIcon, "20px");
              provenance.setCellHorizontalAlignment(
                  commentIcon, HasHorizontalAlignment.ALIGN_RIGHT);
            }

            provenance.add(editIcon);
            provenance.setCellWidth(editIcon, "20px");
            provenance.setCellHorizontalAlignment(editIcon, HasHorizontalAlignment.ALIGN_RIGHT);
            provenance.add(deleteIcon);
            provenance.setCellWidth(deleteIcon, "20px");
            provenance.setCellHorizontalAlignment(deleteIcon, HasHorizontalAlignment.ALIGN_RIGHT);
          } else {
            provenance.setVisible(false);
          }
        } else {
          provenance.clear();

          // TODO Externalize the icon management to the plugins
          if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
            Image ic = new Image(Domeo.resources.multipleLittleIcon());
            ic.setTitle("Annotation on multiple targets");
            provenance.add(ic);
            provenance.setCellWidth(ic, "18px");
          } else if (annotation.getSelector() != null
              && annotation.getSelector().getTarget() instanceof MOnlineImage) {
            Image ic = new Image(Domeo.resources.littleImageIcon());
            ic.setTitle("Annotation on image");
            provenance.add(ic);
            provenance.setCellWidth(ic, "18px");
          } else {
            Image ic = new Image(Domeo.resources.littleTextIcon());
            ic.setTitle("Annotation on text");
            provenance.add(ic);
            provenance.setCellWidth(ic, "18px");
          }

          provenance.add(
              new Label(
                  "By "
                      + annotation.getCreator().getName()
                      + " on "
                      + annotation.getFormattedCreationDate()));

          if (((BooleanPreference)
                  _domeo
                      .getPreferences()
                      .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
              .getValue()) {
            provenance.add(commentIcon);
            provenance.setCellWidth(commentIcon, "20px");
            provenance.setCellHorizontalAlignment(commentIcon, HasHorizontalAlignment.ALIGN_RIGHT);
          }

          provenance.add(editIcon);
          provenance.setCellWidth(editIcon, "20px");
          provenance.setCellHorizontalAlignment(editIcon, HasHorizontalAlignment.ALIGN_RIGHT);
          provenance.add(deleteIcon);
          provenance.setCellWidth(deleteIcon, "20px");
          provenance.setCellHorizontalAlignment(deleteIcon, HasHorizontalAlignment.ALIGN_RIGHT);
        }
      } else {
        provenance.setVisible(false);
      }
    } catch (Exception e) {
      _domeo.getLogger().exception(this, "createProvenanceBar2" + e.getMessage());
    }
  }