• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 2260

Show
Ignore:
Timestamp:
02/24/08 21:54:39 (9 months ago)
Author:
jmoore
Message:

FileParsers : Adding support for PDFs

  • Added PDFBox library
  • Added "application/pdf" format to OMERO3A4
  • Added PdfParser`
Location:
trunk
Files:
5 added
10 modified

  • .classpath (modified) (1 diff)
  • components/model/resources/mappings/acquisition.ome.xml (modified) (1 diff)
  • components/server/ivy.xml (modified) (1 diff)
  • components/server/resources/ome/services/service-ome.api.Search.xml (modified) (2 diffs)
  • components/server/src/ome/services/fulltext/FileParser.java (modified) (4 diffs)
  • components/server/src/ome/services/fulltext/FullTextBridge.java (modified) (1 diff)
  • components/server/src/ome/services/fulltext/PdfParser.java (added)
  • components/server/test/ome/server/itests/search/FileParserTest.java (modified) (3 diffs)
  • components/server/test/ome/server/utests/fileparsers (added)
  • components/server/test/ome/server/utests/fileparsers/ABC123.pdf (added)
  • components/server/test/ome/server/utests/fileparsers/FileParserUnitTest.java (added)
  • lib/repository/PDFBox-0.7.3.jar (added)
  • sql/psql/OMERO3A__4/OMERO3A__3.sql (modified) (1 diff)
  • sql/psql/OMERO3A__4/OMERO3__5.sql (modified) (1 diff)
  • sql/psql/OMERO3A__4/data.sql (modified) (1 diff)

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r2177 r2260  
    117117        <classpathentry exported="true" kind="lib" path="target/libs/xml-apis.jar"/> 
    118118        <classpathentry exported="true" kind="lib" path="target/libs/c3p0.jar"/> 
     119        <classpathentry kind="lib" path="target/libs/activation.jar"/> 
     120        <classpathentry kind="lib" path="target/libs/mail.jar"/> 
     121        <classpathentry kind="lib" path="target/libs/PDFBox.jar"/> 
    119122        <classpathentry kind="output" path="target/eclipse-bin"/> 
    120123</classpath> 
  • trunk/components/model/resources/mappings/acquisition.ome.xml

    r2194 r2260  
    477477                <entry name="text/xml"/> 
    478478                <entry name="text/x-python"/> 
     479                <entry name="application/pdf"/> 
    479480        </enum> 
    480481 
  • trunk/components/server/ivy.xml

    r2252 r2260  
    4343    <dependency org="mail" name="mail" rev="1.4.1" conf="build->default"/> 
    4444    <dependency org="activation" name="activation" rev="1.1.1" conf="build->default"/> 
     45    <dependency org="PDFBox" name="PDFBox" rev="0.7.3" conf="build->default"/> 
    4546    <!-- Duplicated with client/ivy.xml --> 
    4647    <dependency org="omero" name="jbossall-client" rev="${versions.jboss}" conf="build->default"/> 
  • trunk/components/server/resources/ome/services/service-ome.api.Search.xml

    r2257 r2260  
    5454    <constructor-arg> 
    5555      <map> 
    56         <entry key="text/plain" value-ref="fileParser"/> 
    57         <entry key="text/csv"   value-ref="fileParser"/> 
    58         <entry key="text/xml"   value-ref="fileParser"/> 
     56        <entry key="text/plain"        value-ref="fileParser"/> 
     57        <entry key="text/csv"          value-ref="fileParser"/> 
     58        <entry key="text/xml"          value-ref="fileParser"/> 
     59        <entry key="application/pdf"   value-ref="pdfParser"/> 
    5960      </map> 
    6061    </constructor-arg> 
    … …  
    6263   
    6364  <bean id="fileParser" class="ome.services.fulltext.FileParser"/> 
     65  <bean id="pdfParser" class="ome.services.fulltext.PdfParser"/> 
    6466 
    6567  <alias name="persistentEventLogLoader" alias="eventLogLoader"/> 
  • trunk/components/server/src/ome/services/fulltext/FileParser.java

    r2204 r2260  
    3838    private final static Log log = LogFactory.getLog(FileParser.class); 
    3939 
    40     private OmeroContext context; 
     40    protected OmeroContext context; 
    4141 
    4242    public void setApplicationContext(ApplicationContext arg0) 
    … …  
    101101            } 
    102102        } catch (Exception e) { 
    103             log.debug("Implementation threw an exception."); 
     103            log.warn("Implementation threw an exception.", e); 
    104104            return EMPTY; 
    105105        } 
    … …  
    133133                    r.close(); 
    134134                } catch (Exception e) { 
    135                     // May not throw exception 
     135                    log.debug("Error closing " + resource, e); 
    136136                } 
    137137            } 
    … …  
    155155        } 
    156156        return new IteratorWrapper(it); 
     157    } 
     158 
     159    public Iterable<Reader> wrap(Reader r) { 
     160        if (r == null) { 
     161            return EMPTY; 
     162        } 
     163        return wrap(new SingleIterator(r)); 
    157164    } 
    158165 
  • trunk/components/server/src/ome/services/fulltext/FullTextBridge.java

    r2204 r2260  
    241241        } 
    242242 
     243        // However, we're not copying Reader information to the combined field 
     244        // here, because can only read from a reader once. 
     245 
    243246        // Never storing in combined fields, since it's duplicated 
    244         f = new Field(COMBINED, reader); 
    245         if (boost != null) { 
    246             f.setBoost(boost); 
    247         } 
    248         d.add(f); 
     247        /* 
     248         * f = new Field(COMBINED, reader); if (boost != null) { 
     249         * f.setBoost(boost); } d.add(f); 
     250         */ 
    249251    } 
    250252 
  • trunk/components/server/test/ome/server/itests/search/FileParserTest.java

    r2259 r2260  
    1515import java.util.UUID; 
    1616 
     17import ome.api.Search; 
    1718import ome.model.annotations.FileAnnotation; 
    1819import ome.model.core.Image; 
    … …  
    2122import ome.testing.FileUploader; 
    2223 
     24import org.springframework.util.ResourceUtils; 
    2325import org.testng.annotations.Test; 
    2426 
    … …  
    7981 
    8082    } 
     83 
     84    @Test() 
     85    public void testPdfFile() throws Exception { 
     86 
     87        // Test data 
     88 
     89        // Upload 
     90        File file = ResourceUtils 
     91                .getFile("classpath:ome/server/utests/fileparsers/ABC123.pdf"); 
     92        FileUploader upload = new FileUploader(this.factory, file); 
     93        upload.setFormat("application/pdf"); 
     94        try { 
     95            upload.run(); 
     96        } catch (Exception e) { 
     97            // This seems to be throwing an exception 
     98            // when run in the server 
     99        } 
     100 
     101        i = new Image(); 
     102        i.setName("annotated"); // Don't put ABC123 here. 
     103        FileAnnotation fa = new FileAnnotation(); 
     104        fa.setFile(new OriginalFile(upload.getId(), false)); 
     105        i.linkAnnotation(fa); 
     106        i = iUpdate.saveAndReturnObject(i); 
     107        iUpdate.indexObject(i); 
     108 
     109        loginRoot(); 
     110        Search search = this.factory.createSearchService(); 
     111        search.onlyType(Image.class); 
     112        search.onlyIds(i.getId()); 
     113        search.byFullText("annotation:ABC123"); 
     114        assertTrue(search.hasNext()); 
     115    } 
     116 
    81117} 
  • trunk/sql/psql/OMERO3A__4/OMERO3A__3.sql

    r2259 r2260  
    88ALTER TABLE annotations ALTER COLUMN name RENAME to ns; 
    99 
     10INSERT INTO FORMAT (id,permissions,owner_id,group_id,creation_id,value) 
     11    SELECT nextval('seq_format'),-35,0,0,0,'application/pdf'; 
     12 
    1013INSERT INTO dbpatch (currentVersion, currentPatch, previousVersion, previousPatch, message, finished) 
    1114        VALUES ('OMERO3A',  4, 'OMERO3A', 3, 'Database updated.', now()); 
  • trunk/sql/psql/OMERO3A__4/OMERO3__5.sql

    r2259 r2260  
    18891889ALTER TABLE annotations ALTER COLUMN name RENAME to ns; 
    18901890 
     1891INSERT INTO format (id,permissions,owner_id,group_id,creation_id,value) 
     1892    SELECT nextval('seq_format'),-35,0,0,0,'application/pdf'; 
     1893 
    18911894INSERT INTO dbpatch (currentVersion, currentPatch, previousVersion, previousPatch, message, finished) 
    18921895        VALUES ('OMERO3A',  4, 'OMERO3', 5, 'Database updated.', now()); 
  • trunk/sql/psql/OMERO3A__4/data.sql

    r2259 r2260  
    188188insert into format (id,permissions,owner_id,group_id,creation_id,value) 
    189189    select nextval('seq_format'),-35,0,0,0,'text/x-python'; 
     190insert into format (id,permissions,owner_id,group_id,creation_id,value) 
     191    select nextval('seq_format'),-35,0,0,0,'application/pdf'; 
    190192insert into lasertype (id,permissions,owner_id,group_id,creation_id,value) 
    191193    select nextval('seq_lasertype'),-35,0,0,0,'Excimer'; 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/