Search in sources :

Example 1 with FileType

use of aserg.gtf.model.FileType in project Truck-Factor by aserg-ufmg.

the class NewFileInfoDAO method updateLanguageFileInfo.

public int updateLanguageFileInfo(String projectName, String language, List<String> paths) {
    FileType fileType = FileType.getType(language);
    List<Query> queries = new ArrayList<Query>();
    for (String path : paths) {
        if (path.contains("\'"))
            path = path.replace("'", "''");
        String hql = "UPDATE  newfileinfo " + "SET kind = \'" + fileType + "\'  , language = \'" + language + "\', filtered = \'FALSE\' " + ", filterinfo = \'\' " + "WHERE repositoryname = \'" + projectName + "\' AND path =  \'" + path + "\' " + ";";
        queries.add(em.createNativeQuery(hql));
    }
    int rows = 0;
    EntityTransaction tx = this.em.getTransaction();
    try {
        tx.begin();
        for (Query query : queries) {
            rows += query.executeUpdate();
        }
        tx.commit();
    } catch (RuntimeException e) {
        if (tx != null && tx.isActive())
            tx.rollback();
        throw e;
    } finally {
        this.em.clear();
    }
    return rows;
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) Query(javax.persistence.Query) FileType(aserg.gtf.model.FileType) ArrayList(java.util.ArrayList)

Aggregations

FileType (aserg.gtf.model.FileType)1 ArrayList (java.util.ArrayList)1 EntityTransaction (javax.persistence.EntityTransaction)1 Query (javax.persistence.Query)1