001: /*******************************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: *******************************************************************************/package org.ofbiz.shark.audit;
019:
020: import org.ofbiz.base.util.Debug;
021: import org.ofbiz.base.util.UtilMisc;
022: import org.ofbiz.entity.GenericDelegator;
023: import org.ofbiz.entity.GenericEntityException;
024: import org.ofbiz.entity.GenericValue;
025:
026: import org.enhydra.shark.api.internal.eventaudit.StateEventAuditPersistenceInterface;
027:
028: /**
029: * Persistance Object
030: */
031: public class StateEventAudit extends EventAudit implements
032: StateEventAuditPersistenceInterface {
033:
034: public static final String module = AssignmentEventAudit.class
035: .getName();
036: protected GenericValue stateEventAudit = null;
037: private boolean newValue = false;
038:
039: public StateEventAudit(EntityAuditMgr mgr,
040: GenericDelegator delegator, String eventAuditId) {
041: super (mgr, delegator, eventAuditId);
042: if (this .delegator != null) {
043: try {
044: this .stateEventAudit = delegator
045: .findByPrimaryKey(
046: org.ofbiz.shark.SharkConstants.WfStateEventAudit,
047: UtilMisc
048: .toMap(
049: org.ofbiz.shark.SharkConstants.eventAuditId,
050: eventAuditId));
051: } catch (GenericEntityException e) {
052: Debug.logError(e, module);
053: }
054: } else {
055: Debug.logError("Invalid delegator object passed", module);
056: }
057: }
058:
059: public StateEventAudit(EntityAuditMgr mgr,
060: GenericDelegator delegator) {
061: super (mgr, delegator);
062: this .newValue = true;
063: this .stateEventAudit = delegator.makeValue(
064: org.ofbiz.shark.SharkConstants.WfStateEventAudit,
065: UtilMisc.toMap(
066: org.ofbiz.shark.SharkConstants.eventAuditId,
067: this .eventAuditId));
068: }
069:
070: public StateEventAudit(EntityAuditMgr mgr,
071: GenericValue stateEventAudit) {
072: super (mgr, stateEventAudit.getDelegator(), stateEventAudit
073: .getString(org.ofbiz.shark.SharkConstants.eventAuditId));
074: this .stateEventAudit = stateEventAudit;
075: }
076:
077: public void setOldState(String os) {
078: stateEventAudit
079: .set(org.ofbiz.shark.SharkConstants.oldState, os);
080: }
081:
082: public String getOldState() {
083: return stateEventAudit
084: .getString(org.ofbiz.shark.SharkConstants.oldState);
085: }
086:
087: public void setNewState(String ns) {
088: stateEventAudit
089: .set(org.ofbiz.shark.SharkConstants.newState, ns);
090: }
091:
092: public String getNewState() {
093: return stateEventAudit
094: .getString(org.ofbiz.shark.SharkConstants.newState);
095: }
096:
097: public void store() throws GenericEntityException {
098: super .store();
099: if (newValue) {
100: newValue = false;
101: delegator.createOrStore(stateEventAudit);
102: } else {
103: delegator.store(stateEventAudit);
104: }
105: }
106:
107: public void reload() throws GenericEntityException {
108: super .reload();
109: if (!newValue) {
110: stateEventAudit.refresh();
111: }
112: }
113:
114: public void remove() throws GenericEntityException {
115: super.remove();
116: if (!newValue) {
117: delegator.removeValue(stateEventAudit);
118: }
119: }
120: }
|