@Override public boolean deleteByParentId(long parentId) { boolean changed = false; for (Iterator<DraftState> iterator = workflowState.values().iterator(); iterator.hasNext(); ) { DraftState next = iterator.next(); if (next.getParentSchemeId() == parentId) { iterator.remove(); changed = true; } } return changed; }
MockDraftWorkflowSchemeState(DraftWorkflowSchemeStore.DraftState scheme) { this.id = scheme.getId(); this.mappings = Maps.newHashMap(scheme.getMappings()); this.lastModifiedUser = scheme.getLastModifiedUser(); this.lastModifiedDate = scheme.getLastModifiedDate(); this.parentSchemeId = scheme.getParentSchemeId(); }
public Builder(DraftWorkflowSchemeStore.DraftState state) { this.id = state.getId(); this.parentId = state.getParentSchemeId(); this.schemeMap = newHashMap(state.getMappings()); this.lastModifiedDate = state.getLastModifiedDate(); this.lastModifiedUser = state.getLastModifiedUser(); }
private DraftWorkflowScheme toWorkflowScheme(DraftWorkflowSchemeStore.DraftState state) { if (state == null) { return null; } else { final ApplicationUser userByKey = userManager.getUserByKey(state.getLastModifiedUser()); return new DraftWorkflowSchemeImpl(state, userByKey, getWorkflowSchemeObj(state.getParentSchemeId())); } }
DefaultWorkflowSchemeStateBuilder(DraftState state) { super(state); this.parentId = state.getParentSchemeId(); this.lastModifiedDate = state.getLastModifiedDate(); this.lastModifiedUser = state.getLastModifiedUser(); }
@Override public Long getParentId(long id) { DraftState state = get(id); return state != null ? state.getParentSchemeId() : null; }
@Override public DraftState getDraftForParent(long parentId) { for (DraftState state : getAll()) { if (parentId == state.getParentSchemeId()) { return state; } } return null; }
@Override public void update(DraftState state, GenericValue schemeGv) { Long parentId = schemeGv.getLong(SchemeTable.Columns.PARENT); if (parentId == null || !parentId.equals(state.getParentSchemeId())) { throw new DataAccessException("Trying to change the parent of a draft."); } schemeGv.set(SchemeTable.Columns.UPDATED_DATE, currentDate()); schemeGv.set(SchemeTable.Columns.UPDATED_USER, state.getLastModifiedUser()); delegator.store(schemeGv); }
@Override public GenericValue create(DraftState state) { FieldMap fieldMap = FieldMap.build(SchemeTable.Columns.PARENT, state.getParentSchemeId()); fieldMap.add(SchemeTable.Columns.UPDATED_DATE, currentDate()); fieldMap.add(SchemeTable.Columns.UPDATED_USER, state.getLastModifiedUser()); return delegator.createValue(SchemeTable.ENTITY, fieldMap); }