public List<File> getProjectFiles(Project project) { Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); Query q = session.createQuery("from File f where name.project = :project"); q.setEntity("project", project); List<File> files = q.list(); return files; }
protected Project getProject() { String projectId = getParameters().getString("project"); if (projectId == null || projectId.length() == 0) { return null; } return Manager.getStorageInstance().getProject(projectId); }
public static List<ScmChange> getChanges(Project project, String path) { Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); String prefix = ""; java.io.File searchDir = Manager.getStorageInstance().getWorkingDirectory(project); while (project.getParent() != null) { prefix = searchDir.getName() + java.io.File.separatorChar + prefix; project = project.getParent(); searchDir = searchDir.getParentFile(); } Query q = session.createQuery( "from ScmChange c where c.set.id.project = :project and name = :path order by c.set.date desc"); q.setEntity("project", project); q.setString("path", prefix + path); return q.list(); }
public static boolean getChangeSetExists(Project project, String changeId) { Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); Query q = session.createQuery( "select count(*) from ScmChangeSet s where s.id.project = :project and s.revision = :rev"); q.setEntity("project", project); q.setString("rev", changeId); return ((Long) q.uniqueResult()) > 0; }
public static boolean getFileExists(Project project, String fileName) { Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); Query q = session.createQuery( "select count(*) from File f where f.name.project = :project and f.name.name = :name"); q.setEntity("project", project); q.setString("name", fileName); return ((Long) q.uniqueResult()) > 0; }
@Override protected Criteria createCriteria() { Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); Criteria c = session.createCriteria(Issue.class); c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); c.add(filter.getStatusCriterion()); Criterion assignmentRestriction = filter.getAssignmentCriterion(); if (assignmentRestriction != null) { c.add(assignmentRestriction); } return c; }
/** Called whenever the OSGi framework stops our bundle */ public void stop(BundleContext bc) throws Exception { tracker.close(); if ("org.h2.Driver".equals(bc.getProperty("headsup.db.driver"))) { try { ((HibernateStorage) Manager.getStorageInstance()) .getHibernateSession() .createSQLQuery("SHUTDOWN") .executeUpdate(); } catch (Exception e) { Manager.getLogger("StorageActivator").info("Unable to shut down DB - " + e.getMessage()); } } HibernateUtil.shutdown(); }
protected List<Issue> getIssuesAssignedTo(User user) { Session session = ((HibernateStorage) Manager.getStorageInstance()).getHibernateSession(); Query q = session.createQuery( "from Issue i where status < 250 and assignee = :user order by priority, status"); q.setEntity("user", user); List<Issue> list = q.list(); // force loading... for (Issue issue : list) { if (issue.getMilestone() != null) { // force a load issue.getMilestone().getIssues().size(); } issue.getAttachments().size(); } return list; }
private static void addSubTree(String prefix, PropertyTree tree) { Manager.getStorageInstance().getGlobalConfiguration().addSubTree(prefix, tree); }
private static PropertyTree getSubTree(String prefix) { return Manager.getStorageInstance().getGlobalConfiguration().getSubTree(prefix); }
public static void setProperty(String key, String value) { Manager.getStorageInstance().getGlobalConfiguration().setProperty(key, value); }
public static String getProperty(String key, String deflt) { return Manager.getStorageInstance().getGlobalConfiguration().getProperty(key, deflt); }
public String getDescription() { return "The " + Manager.getStorageInstance().getGlobalConfiguration().getProductName() + " scm browse application"; }