public void store() { try { genericValue.store(); } catch (GenericEntityException e) { log.error("Exception whilst trying to store genericValue " + genericValue + ".", e); throw new DataAccessException(e); } }
private static void updateHistoryItemLastViewed(@Nonnull final GenericValue genericValue, final long lastViewed) { genericValue.set(LAST_VIEWED, lastViewed); try { genericValue.store(); } catch (GenericEntityException e) { LOG.error("Exception thrown while updating user history item", e); } }
public void store() { if (gv != null) { try { gv.store(); } catch (GenericEntityException e) { throw new DataAccessException(e); } } }
public void store() { try { gv.store(); } catch (final GenericEntityException e) { throw new DataAccessException(e.getMessage(), e); } }
public void clearColumn(String tableName, String column) { for (final GenericValue row : delegator.findAll(tableName)) { try { row.set(column, null); row.store(); } catch (GenericEntityException e) { log.error("Failed to upgrade table row " + row + " exception being thrown", e); throw new DataAccessException(e); } } }
private void setSystemDefaultForAvatar(Avatar avatar, boolean isSystemAvatar) { try { log.info(String.format("Changing '%s' system avatar status to " + isSystemAvatar, avatar.getFileName())); GenericValue gv = getOfBizDelegator().findById(AVATAR_ENTITY, avatar.getId()); gv.set(SYSTEM_AVATAR_FIELD, isSystemAvatar ? IS_SYSTEM : NOT_SYSTEM); gv.store(); } catch (GenericEntityException e) { log.error(String.format("Error updating '%s' system avatar status", avatar.getFileName()), e); } }
private void fixBrokenIssues(List<BrokenIssue> brokenIssues) throws GenericEntityException, IndexException { for (BrokenIssue brokenIssue : brokenIssues) { final GenericValue issue = ofBizDelegator.findById("Issue", brokenIssue.issueId); if (issue != null) { issue.set("watches", brokenIssue.correctWatches); issue.store(); issueIndexManager.reIndex(issue); } } }
private Node storeFieldMap(@Nonnull Map<String, Object> fields, boolean create) { final GenericValue gv = ofBizDelegator.makeValue(ENTITY, fields); try { if (create) { gv.create(); } else { gv.store(); } } catch (GenericEntityException e) { throw new DataAccessException("Problem storing node", e); } return fromGv(gv); }
void updateIssueKey(final ExternalIssue externalIssue, final GenericValue issueGV) { issueGV.setString("key", externalIssue.getKey()); try { issueGV.store(); } catch (final GenericEntityException e) { final String message = "Unable to set the required key '" + externalIssue.getKey() + "' in the Issue that we just created (id = '" + issueGV.getLong("id") + "')."; log.error(message, e); throw new DataAccessException(message, e); } }
public void doUpgrade() { //retrieve list of Portlet ids with matching key values EntityCondition condition = new EntityExpr(PORTLET_ID, EntityOperator.EQUALS, OLD_NAMESPACE); final List portletIds = delegator.findByCondition(PORTLET_ENTITY, condition, EasyList.build("id"), null); for (Iterator iterator = portletIds.iterator(); iterator.hasNext();) { Long id = null; try { GenericValue portletIdGv = (GenericValue) iterator.next(); id = portletIdGv.getLong("id"); //retrieve and update each Portlet GenericValue gv = EntityUtil.getOnly(delegator.findByAnd(PORTLET_ENTITY, EasyMap.build("id", id))); gv.setString(PORTLET_ID, NEW_NAMESPACE); gv.store(); } catch (GenericEntityException e) { log.error("Failed to update namespace of " + PORTLET_ENTITY + " id=" + id, e); } catch (DataAccessException e) { log.error("Failed to update namespace of " + PORTLET_ENTITY + " id=" + id, e); } } }
/** * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that the table may linger but the sequence ids go * * @param entityName * @param nextId * @throws GenericEntityException */ private void setNextId(String entityName, Long nextId) throws GenericEntityException { final GenericDelegator delegator = getDelegator(); // First ensure we have an entry in SequenecValueItem table delegator.getNextSeqId(entityName); // Now set it to nextId GenericValue sequenceItem = EntityUtil.getOnly(delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName))); if (sequenceItem != null) { sequenceItem.set("seqId", nextId); sequenceItem.store(); delegator.refreshSequencer(); } }
@Override public void updateScheme(final GenericValue entity) throws GenericEntityException { final Long schemeId = entity.getLong("id"); final Scheme originalScheme = getSchemeObject(schemeId); entity.store(); flushProjectSchemes(); eventPublisher.publish(createSchemeUpdatedEvent(getSchemeObject(schemeId), originalScheme)); }
/** * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that the table may linger but the sequence ids go * * @param entityName * @param nextId * @throws GenericEntityException */ private void setNextId(String entityName, Long nextId) throws GenericEntityException { final GenericDelegator delegator = getDelegator(); // First ensure we have an entry in SequenecValueItem table delegator.getNextSeqId(entityName); // Now set it to nextId GenericValue sequenceItem = EntityUtil.getOnly(delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName))); if (sequenceItem != null) { sequenceItem.set("seqId", nextId); sequenceItem.store(); delegator.refreshSequencer(); } } @Nullable
@Override public Attachment setThumbnailable(final Attachment attachment, final boolean thumbnailable) { final GenericValue attachmentGV; try { attachmentGV = ofBizDelegator.findById(AttachmentConstants.ATTACHMENT_ENTITY_NAME, attachment.getId()); attachmentGV.put("thumbnailable", thumbnailable ? IS_THUMBNAILABLE : NOT_THUMBNAILABLE); attachmentGV.store(); } catch (DataAccessException e) { log.error("Unable to find a file attachment with id: " + attachment.getId()); throw e; } catch (GenericEntityException e) { log.error("Unable to find a file attachment with id: " + attachment.getId()); throw new DataAccessException(e); } return new Attachment(issueManager, attachmentGV, attachment.getProperties()); }
@Override public Attachment setZip(final Attachment attachment, final boolean zip) { final GenericValue attachmentGV; try { attachmentGV = ofBizDelegator.findById(AttachmentConstants.ATTACHMENT_ENTITY_NAME, attachment.getId()); attachmentGV.put("zip", zip ? IS_ZIP : NOT_ZIP); attachmentGV.store(); } catch (DataAccessException e) { log.error("Unable to find a file attachment with id: " + attachment.getId()); throw e; } catch (GenericEntityException e) { log.error("Unable to find a file attachment with id: " + attachment.getId()); throw new DataAccessException(e); } return new Attachment(issueManager, attachmentGV, attachment.getProperties()); }
public void updateProjectRole(final ProjectRole projectRole) { try { final GenericValue projectRoleGv = ofBizDelegator.findById(ENTITY_NAME, projectRole.getId()); projectRoleGv.set(PROJECT_ROLE_FIELD_NAME, projectRole.getName()); projectRoleGv.set(PROJECT_ROLE_FIELD_DESCRIPTION, projectRole.getDescription()); projectRoleGv.store(); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
private void disableCloneLinkLegacyDirectionFlag() throws GenericEntityException { //this property exists since we just got true form it final GenericValue flag = entityEngine.run(Select.from("OSPropertyEntry") .whereEqual("propertyKey", JIRA_CLONE_LINK_LEGACY_DIRECTION)).singleValue(); final GenericValue value = entityEngine.run(Select.from("OSPropertyNumber") .whereEqual("id", flag.getLong("id"))).singleValue(); value.set("value", 0); value.store(); }
/** * Adjusts the watch count for an issue. * * @param originalIssue the issue to change count for * @param adjustValue the value to change it by * @throws GenericEntityException If there wasa persitence problem */ private Issue adjustWatchCount(final Issue originalIssue, final int adjustValue) throws GenericEntityException { final long watches = recalculateWatches(originalIssue, adjustValue); final Long issueId = originalIssue.getId(); final GenericValue clonedIssue = (GenericValue) originalIssue.getGenericValue().clone(); clonedIssue.clear(); clonedIssue.set("id", issueId); clonedIssue.set("watches", watches); clonedIssue.store(); // indexing doesn't handles incremental updates, re-indexing the updated object from db return issueManager.getIssueObject(issueId); }
public FieldConfig update(final FieldConfig config) { try { final GenericValue gv = findById(config.getId()); final Map<String, Object> fields = transformToFieldsMap(config); gv.setNonPKFields(fields); gv.store(); fieldConfigsById.reset(); final CustomField customField = config.getCustomField(); return transformToDomainObject(gv, customField.getConfigurationItemTypes()); } catch (final GenericEntityException e) { throw new DataAccessException("Unable to store FieldConfig: " + config, e); } }
public FieldConfigScheme update(final FieldConfigScheme configScheme) { try { final GenericValue gv = findById(configScheme.getId()); final Map<String,Object> fields = transformToFieldsMap(configScheme); gv.setNonPKFields(fields); gv.store(); // Recreated config relations removeRelatedConfigsForUpdate(configScheme, gv); gv.removeRelated(FK_RELATED_CONFIGS); storeConfigAssociations(configScheme.getConfigs(), configScheme.getId()); invalidateAll(); return getFieldConfigScheme(configScheme.getId()); } catch (final GenericEntityException e) { throw new DataAccessException("Unable to store FieldConfigScheme: " + configScheme, e); } }