Search in sources :

Example 1 with CfContentversion

use of io.clownfish.clownfish.dbentities.CfContentversion in project Clownfish by rawdog71.

the class CfContentversionDAOImpl method findByContentref.

@Override
public List<CfContentversion> findByContentref(long ref) {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfContentversion.findByContentref");
    query.setParameter("contentref", ref);
    List<CfContentversion> CfContentversionlist = query.getResultList();
    return CfContentversionlist;
}
Also used : TypedQuery(javax.persistence.TypedQuery) CfContentversion(io.clownfish.clownfish.dbentities.CfContentversion) Session(org.hibernate.Session)

Example 2 with CfContentversion

use of io.clownfish.clownfish.dbentities.CfContentversion in project Clownfish by rawdog71.

the class CfContentversionDAOImpl method findByPK.

@Override
public CfContentversion findByPK(long ref, long version) {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfContentversion.findByPK");
    query.setParameter("contentref", ref);
    query.setParameter("version", version);
    CfContentversion cfcontentversion = (CfContentversion) query.getSingleResult();
    return cfcontentversion;
}
Also used : TypedQuery(javax.persistence.TypedQuery) CfContentversion(io.clownfish.clownfish.dbentities.CfContentversion) Session(org.hibernate.Session)

Example 3 with CfContentversion

use of io.clownfish.clownfish.dbentities.CfContentversion in project Clownfish by rawdog71.

the class ContentList method writeVersion.

public void writeVersion(long ref, long version, byte[] content) {
    CfContentversionPK contentversionpk = new CfContentversionPK();
    contentversionpk.setContentref(ref);
    contentversionpk.setVersion(version);
    CfContentversion cfcontentversion = new CfContentversion();
    cfcontentversion.setCfContentversionPK(contentversionpk);
    cfcontentversion.setContent(content);
    cfcontentversion.setTstamp(new Date());
    cfcontentversion.setCommitedby(BigInteger.valueOf(loginbean.getCfuser().getId()));
    cfcontentversionService.create(cfcontentversion);
}
Also used : CfContentversionPK(io.clownfish.clownfish.dbentities.CfContentversionPK) CfContentversion(io.clownfish.clownfish.dbentities.CfContentversion) Date(java.util.Date)

Example 4 with CfContentversion

use of io.clownfish.clownfish.dbentities.CfContentversion in project Clownfish by rawdog71.

the class ContentUtil method getVersion.

@Override
public String getVersion(long ref, long version) {
    try {
        CfContentversion contentversion = cfcontentversionService.findByPK(ref, version);
        byte[] decompress = CompressionUtils.decompress(contentversion.getContent());
        return new String(decompress, StandardCharsets.UTF_8);
    } catch (IOException | DataFormatException ex) {
        LOGGER.error(ex.getMessage());
        return null;
    }
}
Also used : DataFormatException(java.util.zip.DataFormatException) CfContentversion(io.clownfish.clownfish.dbentities.CfContentversion) IOException(java.io.IOException)

Example 5 with CfContentversion

use of io.clownfish.clownfish.dbentities.CfContentversion in project Clownfish by rawdog71.

the class CfContentversionDAOImpl method findAll.

@Override
public List<CfContentversion> findAll() {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfContentversion.findAll");
    List<CfContentversion> cfcontentversionlist = query.getResultList();
    return cfcontentversionlist;
}
Also used : TypedQuery(javax.persistence.TypedQuery) CfContentversion(io.clownfish.clownfish.dbentities.CfContentversion) Session(org.hibernate.Session)

Aggregations

CfContentversion (io.clownfish.clownfish.dbentities.CfContentversion)7 CfContentversionPK (io.clownfish.clownfish.dbentities.CfContentversionPK)3 Date (java.util.Date)3 TypedQuery (javax.persistence.TypedQuery)3 Session (org.hibernate.Session)3 IOException (java.io.IOException)1 DataFormatException (java.util.zip.DataFormatException)1