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;
}
Aggregations