Ignore:
Timestamp:
12/19/13 14:36:04 (10 years ago)
Author:
olhsha
Message:

adding trasnactional, refactoring and fixing bugs in updated annotations, removing try-catch from resource methods (The Greek's advice)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java

    r4181 r4207  
    4040import eu.dasish.annotation.schema.User;
    4141import eu.dasish.annotation.schema.UserWithPermission;
     42import java.io.IOException;
    4243import java.io.InputStream;
    4344import java.lang.Number;
     45import java.sql.SQLException;
    4446import java.sql.Timestamp;
    4547import java.util.ArrayList;
     
    4850import java.util.Map;
    4951import java.util.UUID;
     52import javax.xml.parsers.ParserConfigurationException;
    5053import org.springframework.beans.factory.annotation.Autowired;
    5154import org.slf4j.Logger;
    5255import org.slf4j.LoggerFactory;
     56import org.springframework.transaction.annotation.Transactional;
    5357
    5458/**
     
    9498    }
    9599
    96     ///////////// GETTERS //////////////////////////
     100   
    97101    @Override
    98102    public Number getTargetInternalIdentifier(UUID externalID) {
     
    189193    ////////////////////////////////////////////////////////////////////////
    190194    @Override
    191     public List<Number> getFilteredAnnotationIDs(String link, String text, Number inloggedUserID, String access, String namespace, UUID owner, Timestamp after, Timestamp before) {
    192 
    193         if (access == null) {
    194             return null;
    195         }
    196 
    197         List<Number> annotationIDs = annotationDao.getAnnotationIDsForUserWithPermission(inloggedUserID, access);
     195    public List<Number> getFilteredAnnotationIDs(String link, String text, Number inloggedUserID, String[] accessModes, String namespace, UUID owner, Timestamp after, Timestamp before) {
     196
     197        if (accessModes == null) {
     198            return null;
     199        }
     200
     201        List<Number> annotationIDs = annotationDao.getAnnotationIDsForUserWithPermission(inloggedUserID, accessModes);
    198202
    199203        if (link != null) {
     
    258262
    259263    @Override
    260     public AnnotationInfoList getFilteredAnnotationInfos(String word, String text, Number inloggedUserID, String access, String namespace, UUID owner, Timestamp after, Timestamp before) {
    261         List<Number> annotationIDs = getFilteredAnnotationIDs(word, text, inloggedUserID, access, namespace, owner, after, before);
     264    public AnnotationInfoList getFilteredAnnotationInfos(String word, String text, Number inloggedUserID, String[] accessModes, String namespace, UUID owner, Timestamp after, Timestamp before) {
     265        List<Number> annotationIDs = getFilteredAnnotationIDs(word, text, inloggedUserID, accessModes, namespace, owner, after, before);
    262266        if (annotationIDs != null) {
    263267            AnnotationInfoList result = new AnnotationInfoList();
     
    388392    @Override
    389393    public int updateAnnotationBody(Number internalID, AnnotationBody annotationBody) {
    390         return annotationDao.updateAnnotationBody(internalID, annotationBody);
     394        String[] body = annotationDao.retrieveBodyComponents(annotationBody);
     395        return annotationDao.updateAnnotationBody(internalID, body[0], body[1], annotationBody.getXmlBody()!=null);
    391396    }
    392397   
     
    518523        String bodyText;
    519524        String newBodyText;
     525        String mimeType;
    520526        if (annotationBody.getXmlBody() != null) {
    521527            bodyText = Helpers.elementToString(annotation.getBody().getXmlBody().getAny());
     528            mimeType = annotationBody.getXmlBody().getMimeType();
    522529        } else {
    523530            if (annotation.getBody().getTextBody() != null) {
    524531                bodyText = annotation.getBody().getTextBody().getValue();
    525 
     532                mimeType = annotationBody.getTextBody().getMimeType();
    526533            } else {
    527534                logger.error("The client has sent ill-formed annotation body.");
     
    530537        }
    531538        newBodyText = Helpers.replace(bodyText, targetIdPairs);
    532         return annotationDao.updateAnnotationBodyText(annotationID, newBodyText);
     539        return annotationDao.updateAnnotationBody(annotationID, newBodyText, mimeType, annotationBody.getXmlBody() != null);
    533540    }
    534541
Note: See TracChangeset for help on using the changeset viewer.