@Override public ChangeItemBean createAttachment(final File file, final String filename, final String contentType, @Nullable final ApplicationUser remoteUser, final GenericValue issue) throws AttachmentException { return createAttachment(file, filename, contentType, remoteUser, issue, Collections.<String, Object>emptyMap(), nowTimestamp()); }
@Override public ChangeItemBean createAttachment(final File file, final String filename, final String contentType, @Nullable final ApplicationUser remoteUser, final Issue issue) throws AttachmentException { return createAttachment(file, filename, contentType, remoteUser, issue, Collections.<String, Object>emptyMap(), nowTimestamp()); }
/** *returns the values that are currently active. * *@param datedValues GenericValue's that have "fromDate" and "thruDate" fields *@param allAreSame Specifies whether all values in the List are of the same entity; this can help speed things up a fair amount since we only have to see if the from and thru date fields are valid once *@return List of GenericValue's that are currently active */ public static List filterByDate(List datedValues, boolean allAreSame) { return filterByDate(datedValues, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", allAreSame); }
/** * returns the values that are currently active. * * @param datedValues GenericValue's that have "fromDate" and "thruDate" fields * @return List of GenericValue's that are currently active */ public static <T extends GenericEntity> List<T> filterByDate(List<T> datedValues) { return filterByDate(datedValues, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); }
/** * returns the values that are currently active. * * @param datedValues GenericValue's that have "fromDate" and "thruDate" fields * @param allAreSame Specifies whether all values in the List are of the same entity; this can help speed things up a fair amount since we only have to see if the from and thru date fields are valid once * @return List of GenericValue's that are currently active */ public static <T extends GenericEntity> List<T> filterByDate(List<T> datedValues, boolean allAreSame) { return filterByDate(datedValues, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", allAreSame); }
/** *returns the values that are currently active. * *@param datedValues GenericValue's that have "fromDate" and "thruDate" fields *@return List of GenericValue's that are currently active */ public static List filterByDate(List datedValues) { return filterByDate(datedValues, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); }
/** *returns the values that are currently active. * *@param datedValues GenericValue's that have "fromDate" and "thruDate" fields *@return List of GenericValue's that are currently active */ public static List filterByDate(List datedValues) { return filterByDate(datedValues, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", true); }
/** *returns the values that are currently active. * *@param datedValues GenericValue's that have "fromDate" and "thruDate" fields *@param allAreSame Specifies whether all values in the List are of the same entity; this can help speed things up a fair amount since we only have to see if the from and thru date fields are valid once *@return List of GenericValue's that are currently active */ public static List filterByDate(List datedValues, boolean allAreSame) { return filterByDate(datedValues, UtilDateTime.nowTimestamp(), "fromDate", "thruDate", allAreSame); }
public ChangeItemBean createAttachment(final MultiPartRequestWrapper requestWrapper, final ApplicationUser remoteUser, final GenericValue issue, final String fileParamName, final Map<String, Object> attachmentProperties) throws AttachmentException { final File file = requestWrapper.getFile(fileParamName); if (file == null) //there's not much we can do here. { log.warn(format("Could not create attachment. No file found in MultiPartRequestWrapper. File param name: %s. Request wrapper file names: %s.", fileParamName, CollectionBuilder.list(requestWrapper.getFileNames()))); return null; } final String filename = requestWrapper.getFilesystemName(fileParamName); final String contentType = requestWrapper.getContentType(fileParamName); return attachmentManager.createAttachment(file, filename, contentType, remoteUser, issue, attachmentProperties, UtilDateTime.nowTimestamp()); }
@Deprecated public static GenericValue setPriority(GenericValue issue, ApplicationUser remoteUser, String priority) throws GenericEntityException { final GenericValue originalIssue = ComponentAccessor.getIssueManager().getIssue(issue.getLong("id")); issue.setString(IssueFieldConstants.PRIORITY, priority); issue.set("updated", UtilDateTime.nowTimestamp()); GenericValue changeGroup = ChangeLogUtils.createChangeGroup(remoteUser, originalIssue, issue, Collections.<ChangeItemBean>emptyList(), true); ComponentAccessor.getOfBizDelegator().storeAll(Arrays.asList(issue)); return changeGroup; }
protected boolean updateIssueStatusAndUpdatedDate(GenericValue issue, GenericValue newStatus) { if (!issue.getString("status").equals(newStatus.getString("id"))) { issue.set("updated", UtilDateTime.nowTimestamp()); issue.set("status", newStatus.getString("id")); return true; } else { return false; } }
public void doUpdate(IssueUpdateBean iub, boolean generateChangeItems) { iub.getChangedIssue().set(IssueFieldConstants.UPDATED, UtilDateTime.nowTimestamp()); // We want to store the fields that have changed, not the whole issue. Unfortunately, IssueUpdateBean.getChangeItems() can be incomplete, // so we need to compare the before and after issues to compute the list of modified fields. final List<ChangeItemBean> changeItems = ChangeLogUtils.generateChangeItems(iub.getOriginalIssue(), iub.getChangedIssue()); int size = changeItems.size() + (iub.getChangeItems() == null ? 0 : iub.getChangeItems().size()); List<ChangeItemBean> modifiedFields = Lists.newArrayListWithCapacity(size); modifiedFields.addAll(changeItems); if (iub.getChangeItems() != null) { modifiedFields.addAll(iub.getChangeItems()); } if (!(modifiedFields.isEmpty() && iub.getComment() == null)) { storeModifiedFields(iub, generateChangeItems, modifiedFields); } }
@VisibleForTesting void alertSystemOfComment(Comment comment) throws GenericEntityException { final MutableIssue issueObject = getMutableIssue(); issueObject.setUpdated(UtilDateTime.nowTimestamp()); issueObject.store(); // fire a comment event Map<String, Object> params = createIssueEventParameters(); issueEventManager.dispatchRedundantEvent(ISSUE_COMMENTED_ID, issueObject, getLoggedInUser(), comment, null, null, params); IssueEventBundle issueCommentBundle = issueEventBundleFactory.createCommentAddedBundle(issueObject, getLoggedInUser(), comment, params); issueEventManager.dispatchEvent(issueCommentBundle); }
private List<ChangeItemBean> convertTemporaryAttachments(final ApplicationUser user, final Issue issue, final List<Long> selectedAttachments, final TemporaryAttachmentsMonitor temporaryAttachmentsMonitor, final String attachScreenshotFileName) throws AttachmentException { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // NOTE: this method has been copied from attachment manager and changed to accept fileName specified in Screenshot Attachment Dialog ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// notNull("issue", issue); notNull("attachScreenshotFileName", attachScreenshotFileName); notNull("selectedAttachments", selectedAttachments); notNull("temporaryAttachmentsMonitor", temporaryAttachmentsMonitor); final List<ChangeItemBean> ret = new ArrayList<ChangeItemBean>(); for (final Long selectedAttachment : selectedAttachments) { final TemporaryAttachment tempAttachment = temporaryAttachmentsMonitor.getById(selectedAttachment); final ChangeItemBean cib = attachmentManager.createAttachment(tempAttachment.getFile(), attachScreenshotFileName, tempAttachment.getContentType(), user, issue, Collections.<String, Object>emptyMap(), UtilDateTime.nowTimestamp()); if (cib != null) { ret.add(cib); } } //finally clear any other remaining temp attachments for give form token temporaryAttachmentsMonitor.clearEntriesForFormToken(formToken); return ret; } }
/** * Stores any changes to the issue optionally including a changelog and * conditionally dispatches an IssueUpdate event. * @param iub the description of the change. */ void doUpdate(IssueUpdateBean iub) { final GenericValue changedIssue = iub.getChangedIssue(); changedIssue.set("updated", UtilDateTime.nowTimestamp()); ofBizDelegator.storeAll(EasyList.build(changedIssue)); GenericValue changeGroup = ChangeLogUtils.createChangeGroup(iub.getApplicationUser(), iub.getOriginalIssue(), changedIssue, iub.getChangeItems(), true); //always fire events if something has changed if (iub.isDispatchEvent()) { dispatchEvent(iub, changedIssue, changeGroup); } }
builder.add("created", UtilDateTime.nowTimestamp()); changeGroup = delegator.createValue("ChangeGroup", builder.toMap());
entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp());
private int singleInsert(GenericEntity entity, ModelEntity modelEntity, List fieldsToSave, Connection connection) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { return singleUpdateView(entity, (ModelViewEntity) modelEntity, fieldsToSave, connection); } // if we have a STAMP_FIELD then set it with NOW. if (modelEntity.isField(ModelEntity.STAMP_FIELD)) { entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp()); } String sql = "INSERT INTO " + modelEntity.getTableName(datasourceInfo) + " (" + modelEntity.colNameString(fieldsToSave) + ") VALUES (" + modelEntity.fieldsStringList(fieldsToSave, "?", ", ") + ")"; SQLProcessor sqlP = new PassThruSQLProcessor(helperName, connection); try { sqlP.prepareStatement(sql); SqlJdbcUtil.setValues(sqlP, fieldsToSave, entity, modelFieldTypeReader); int retVal = sqlP.executeUpdate(); entity.modified = false; if (entity instanceof GenericValue) { ((GenericValue) entity).copyOriginalDbValues(); } return retVal; } catch (GenericEntityException e) { throw new GenericEntityException("while inserting: " + entity.toString(), e); } finally { sqlP.close(); } }
private int singleInsert(GenericEntity entity, ModelEntity modelEntity, List<ModelField> fieldsToSave, Connection connection) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { return singleUpdateView(entity, (ModelViewEntity) modelEntity, fieldsToSave, connection); } // if we have a STAMP_FIELD then set it with NOW. if (modelEntity.isField(ModelEntity.STAMP_FIELD)) { entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp()); } final String sql = "INSERT INTO " + modelEntity.getTableName(datasourceInfo) + " (" + modelEntity.colNameString(fieldsToSave) + ") VALUES (" + modelEntity.fieldsStringList(fieldsToSave, "?", ", ") + ')'; SQLProcessor sqlP = new PassThruSQLProcessor(helperName, connection); try { sqlP.prepareStatement(sql); SqlJdbcUtil.setValues(sqlP, fieldsToSave, entity, modelFieldTypeReader); int retVal = sqlP.executeUpdate(); entity.modified = false; if (entity instanceof GenericValue) { ((GenericValue) entity).copyOriginalDbValues(); } return retVal; } catch (GenericEntityException e) { throw new GenericEntityException("while inserting: " + entity.toString(), e); } finally { closeSafely(sql, sqlP); } }
private int singleInsert(GenericEntity entity, ModelEntity modelEntity, List fieldsToSave, Connection connection) throws GenericEntityException { if (modelEntity instanceof ModelViewEntity) { return singleUpdateView(entity, (ModelViewEntity) modelEntity, fieldsToSave, connection); } // if we have a STAMP_FIELD then set it with NOW. if (modelEntity.isField(ModelEntity.STAMP_FIELD)) { entity.set(ModelEntity.STAMP_FIELD, UtilDateTime.nowTimestamp()); } String sql = "INSERT INTO " + modelEntity.getTableName(datasourceInfo) + " (" + modelEntity.colNameString(fieldsToSave) + ") VALUES (" + modelEntity.fieldsStringList(fieldsToSave, "?", ", ") + ")"; SQLProcessor sqlP = new PassThruSQLProcessor(helperName, connection); try { sqlP.prepareStatement(sql); SqlJdbcUtil.setValues(sqlP, fieldsToSave, entity, modelFieldTypeReader); int retVal = sqlP.executeUpdate(); entity.modified = false; if (entity instanceof GenericValue) { ((GenericValue) entity).copyOriginalDbValues(); } return retVal; } catch (GenericEntityException e) { throw new GenericEntityException("while inserting: " + entity.toString(), e); } finally { sqlP.close(); } }