List of usage examples for org.hibernate.type LongType INSTANCE
LongType INSTANCE
To view the source code for org.hibernate.type LongType INSTANCE.
Click Source Link
From source file:org.squashtest.tm.internal.domain.report.common.hibernate.HibernateRequirementCoverageByTestsQuery.java
License:Open Source License
private List<Long> idsByProject(Session session) { List<Long> projectIds = new ArrayList<>(); boolean runOnAllProjects = true; if (this.getCriterions().get(PROJECT_IDS).getParameters() != null) { runOnAllProjects = false;// w w w . j a v a 2 s. c o m // Put ids in a list for (Object id : this.getCriterions().get(PROJECT_IDS).getParameters()) { projectIds.add(Long.parseLong((String) id)); } } String hql = "select req.id from Requirement req"; if (!runOnAllProjects) { hql += " where req.project.id in (:projectIds)"; } Query query = session.createQuery(hql); if (!runOnAllProjects) { query.setParameterList("projectIds", projectIds, LongType.INSTANCE); } return query.list(); }
From source file:org.squashtest.tm.internal.domain.report.common.hibernate.HibernateRequirementCoverageByTestsQuery.java
License:Open Source License
private List<Requirement> findRequirements(Session session, List<Long> ids) { if (ids.isEmpty()) { return Collections.emptyList(); }/*from w ww .j av a2 s . co m*/ return session.createQuery("from Requirement where id in (:ids)") .setParameterList("ids", ids, LongType.INSTANCE).list(); }
From source file:org.squashtest.tm.internal.domain.report.common.hibernate.HibernateRequirementCoverageByTestsQuery.java
License:Open Source License
private List<Object[]> findParentsNames(Session session, List<Long> ids) { if (ids.isEmpty()) { return Collections.emptyList(); }/* w w w . ja va2s .c o m*/ return session.createSQLQuery(FIND_REQUIREMENT_PARENT_NAMES) .setParameterList("reqIds", ids, LongType.INSTANCE).list(); }
From source file:org.squashtest.tm.service.internal.batchexport.ExportDao.java
License:Open Source License
@SuppressWarnings("unchecked") private <R> List<R> findModels(Session session, String query, List<Long> tcIds, Class<R> resclass) { Query q = session.getNamedQuery(query); q.setParameterList("testCaseIds", tcIds, LongType.INSTANCE); q.setResultTransformer(new EasyConstructorResultTransformer(resclass)); return q.list(); }
From source file:org.squashtest.tm.service.internal.batchexport.ExportDao.java
License:Open Source License
@SuppressWarnings("unchecked") private <R> List<R> findRequirementModels(String queryName, List<Long> versionIds, Class<R> resclass) { Session session = getStatelessSession(); Query q = session.getNamedQuery(queryName); q.setParameterList("versionIds", versionIds, LongType.INSTANCE); q.setResultTransformer(new EasyConstructorResultTransformer(resclass)); return q.list(); }
From source file:org.squashtest.tm.service.internal.batchimport.Model.java
License:Open Source License
@SuppressWarnings("unchecked") private List<InternalStepModel> loadStepsModel(Long tcId) { Query query = getCurrentSession().getNamedQuery("testStep.findBasicInfosByTcId"); query.setParameter("tcId", tcId, LongType.INSTANCE); List<Object[]> stepdata = query.list(); List<InternalStepModel> steps = new ArrayList<>(stepdata.size()); for (Object[] tuple : stepdata) { StepType type = StepType.valueOf((String) tuple[0]); TestCaseTarget calledTC = null;//from w ww . j a v a2s. c om boolean delegates = false; if (type == StepType.CALL) { String path = finderService.getPathAsString((Long) tuple[1]); calledTC = new TestCaseTarget(path); delegates = (Boolean) tuple[2]; } steps.add(new InternalStepModel(type, calledTC, delegates)); } return steps; }
From source file:org.squashtest.tm.service.internal.campaign.CampaignStatisticsServiceImpl.java
License:Open Source License
@Override @PreAuthorize(PERM_CAN_READ_CAMPAIGN + OR_HAS_ROLE_ADMIN) public CampaignProgressionStatistics gatherCampaignProgressionStatistics(long campaignId) { CampaignProgressionStatistics progression = new CampaignProgressionStatistics(); Session session = em.unwrap(Session.class); Query query = session.getNamedQuery("CampaignStatistics.findScheduledIterations"); query.setParameter("id", campaignId, LongType.INSTANCE); List<ScheduledIteration> scheduledIterations = query.list(); //TODO : have the db do the job for me Query requery = session.getNamedQuery("CampaignStatistics.findExecutionsHistory"); requery.setParameter("id", campaignId, LongType.INSTANCE); requery.setParameterList("nonterminalStatuses", ExecutionStatus.getNonTerminatedStatusSet()); List<Date> executionHistory = requery.list(); try {//from w w w . j av a 2 s . com // scheduled iterations progression.setScheduledIterations(scheduledIterations); //we want them in any case ScheduledIteration.checkIterationsDatesIntegrity(scheduledIterations); progression.computeSchedule(); // actual executions progression.computeCumulativeTestPerDate(executionHistory); } catch (IllegalArgumentException ex) { if (LOGGER.isInfoEnabled()) { LOGGER.info("CampaignStatistics : could not generate campaign progression statistics for campaign " + campaignId + " : some iterations scheduled dates are wrong"); } progression.addi18nErrorMessage(ex.getMessage()); } return progression; }
From source file:org.squashtest.tm.service.internal.campaign.CampaignStatisticsServiceImpl.java
License:Open Source License
@Override public List<CampaignTestInventoryStatistics> gatherFolderTestInventoryStatistics(Collection<Long> campaignIds) { List<Object[]> tuples = Collections.emptyList(); if (!campaignIds.isEmpty()) { Query query = em.unwrap(Session.class).getNamedQuery("CampaignFolderStatistics.testinventory"); query.setParameterList("campaignIds", campaignIds, LongType.INSTANCE); tuples = query.list();//from ww w .ja v a2 s . co m } return processCampaignTestInventory(tuples); }
From source file:org.squashtest.tm.service.internal.campaign.CampaignStatisticsServiceImpl.java
License:Open Source License
/** * Execute a named query that accepts as argument a parameter of type List<Long> named "campaignIds", and that * returns a list of tuples (namely Object[]) * * @return/* w ww . j av a 2 s .c o m*/ */ private List<Object[]> fetchCommonTuples(String queryName, List<Long> campaignIds) { List<Object[]> res = Collections.emptyList(); if (!campaignIds.isEmpty()) { Query query = em.unwrap(Session.class).getNamedQuery(queryName); query.setParameterList("campaignIds", campaignIds, LongType.INSTANCE); res = query.list(); } return res; }
From source file:org.squashtest.tm.service.internal.campaign.IterationStatisticsServiceImpl.java
License:Open Source License
@Override public IterationProgressionStatistics gatherIterationProgressionStatistics(long iterationId) { IterationProgressionStatistics progression = new IterationProgressionStatistics(); Session session = getCurrentSession(); Query query = session.getNamedQuery("IterationStatistics.findScheduledIterations"); query.setParameter("id", iterationId, LongType.INSTANCE); ScheduledIteration scheduledIteration = (ScheduledIteration) query.uniqueResult(); //TODO : have the db do the job for me Query requery = session.getNamedQuery("IterationStatistics.findExecutionsHistory"); requery.setParameter("id", iterationId, LongType.INSTANCE); requery.setParameterList("nonterminalStatuses", ExecutionStatus.getNonTerminatedStatusSet()); List<Date> executionHistory = requery.list(); try {/*from w w w . ja v a 2s . com*/ progression.setScheduledIteration(scheduledIteration); ScheduledIteration.checkIterationDatesAreSet(scheduledIteration); progression.computeSchedule(); // actual executions progression.computeCumulativeTestPerDate(executionHistory); } catch (IllegalArgumentException ex) { if (LOGGER.isInfoEnabled()) { LOGGER.info( "CampaignStatistics : could not generate iteration progression statistics for iteration " + iterationId + " : some dates are wrong"); } progression.addi18nErrorMessage(ex.getMessage()); } return progression; }