/** * Move the result set cursor to the beginning of the last page * */ @Transactional public void last() { setFirstResult( getLastFirstResult().intValue() ); }
public TransactionMetadata(AnnotatedElement element) { annotationPresent = element.isAnnotationPresent(Transactional.class); if (annotationPresent) { propType = element.getAnnotation(Transactional.class).value(); } }
/** * Get the index of the first result of the last page * */ @Transactional public Long getLastFirstResult() { Integer pc = getPageCount(); return pc==null ? null : ( pc.longValue()-1 ) * getMaxResults(); }
@Override @Transactional public boolean isNextExists() { return resultList!=null && getMaxResults()!=null && resultList.size() > getMaxResults(); }
@Override @Transactional public boolean isNextExists() { return resultList!=null && getMaxResults()!=null && resultList.size() > getMaxResults(); }
@Transactional public Object getAsObject(FacesContext facesContext, UIComponent cmp, String value) throws ConverterException { if (value == null || value.length() == 0) { return null; } return getEntityLoader().get(value); }
/** * Wrap the result set in a JSF {@link DataModel} * * Delegates to {@link DataModels#getDataModel(Query)} * */ @Transactional public DataModel getDataModel() { if (dataModel==null) { dataModel = DataModels.instance().getDataModel(this); } return dataModel; }
@SuppressWarnings("unchecked") @Transactional public String getAsString(FacesContext facesContext, UIComponent cmp, Object value) throws ConverterException { if (value == null) { return null; } if (value instanceof String) { return (String) value; } return getEntityLoader().put(value); }
@Transactional public String update() { getSession().flush(); updatedMessage(); raiseAfterTransactionSuccessEvent(); return "updated"; }
/** * Get the total number of pages * */ @Transactional public Integer getPageCount() { if ( getMaxResults()==null ) { return null; } else { int rc = getResultCount().intValue(); int mr = getMaxResults().intValue(); int pages = rc / mr; return rc % mr == 0 ? pages : pages+1; } }
/** * Get the managed entity, using the id from {@link #getId()} to load it from * the Persistence Context or creating a new instance if the id is not * defined. * * @see #getId() */ @Transactional public E getInstance() { joinTransaction(); if (instance==null) { initInstance(); } return instance; }
@Transactional @Override public Long getResultCount() { if (isAnyParameterDirty()) { refresh(); } initResultCount(); return resultCount; }
/** * Assign the TaskInstance with the id passed * in the request parameter named "taskId" to * the given actor id. * * @param actorId the jBPM actor id * @return a null outcome only if the task was not found */ @Transactional public String assign(String actorId) { TaskInstance taskInstance = getTaskInstance(); if (taskInstance!=null) { taskInstance.setActorId(actorId); return "taskAssigned"; } else { return null; } }
/** * Unassign the TaskInstance with the id passed * in the request parameter named "taskId" from * the actor to which it is assigned, and return * it to the pool it came from. * * @return a null outcome only if the task was not found */ @Transactional public String unassign() { TaskInstance taskInstance = getTaskInstance(); if (taskInstance!=null) { taskInstance.setActorId(null); return "taskUnassigned"; } else { return null; } }
@Transactional public String remove() { getSession().delete( getInstance() ); getSession().flush(); deletedMessage(); raiseAfterTransactionSuccessEvent(); return "removed"; }
@Transactional @Override public E getSingleResult() { if (isAnyParameterDirty()) { refresh(); } initSingleResult(); return singleResult; }
/** * Store an entity id/clazz * @param entity The entity to store * @return The key under which the clazz/id are stored */ @Transactional public String put(Object entity) { return EntityIdentifierStore.instance().put(createIdentifier(entity), entity); }
/** * @return the TaskInstance with the id passed * in the request parameter named "taskId". */ @Transactional public TaskInstance getTaskInstance() { String[] values = Parameters.instance().getRequestParameters().get("taskId"); if ( values==null || values.length!=1 ) { return null; } else { String taskId = values[0]; return taskId==null ? null : ManagedJbpmContext.instance().getTaskInstanceForUpdate( Long.parseLong(taskId) ); } }
@Unwrap @Transactional public List<TaskInstance> getPooledTaskInstanceList() { Actor actor = Actor.instance(); String actorId = actor.getId(); if ( actorId == null ) return null; ArrayList groupIds = new ArrayList( actor.getGroupActorIds() ); groupIds.add(actorId); return ManagedJbpmContext.instance().getGroupTaskList(groupIds); }
/** * Get the number of results this query returns * * Any changed restriction values will be applied */ @Transactional @Override public Long getResultCount() { if (isAnyParameterDirty()) { refresh(); } initResultCount(); return resultCount; }