001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package mocks.elements;
018:
019: import org.jdom.Element;
020:
021: import edu.iu.uis.eden.WorkflowServiceErrorImpl;
022: import edu.iu.uis.eden.exception.InvalidXmlException;
023: import edu.iu.uis.eden.services.InconsistentDocElementStateException;
024: import edu.iu.uis.eden.services.ServiceErrorConstants;
025:
026: /**
027: * <p>Title: OrgCodeElement </p>
028: * <p>Description: Business respresentation of a OrgCode both in XML and \
029: * business rules. <br><BR>
030: * See IDocElement documentation for
031: * further explanation.</p>
032: *
033: * <p>Copyright: Copyright (c) 2002</p>
034: * <p>Company: Indiana University</p>
035: * @author Ryan Kirkendall
036: * @version 1.0
037: */
038: public class OrgCodeElement implements IDocElement {
039: /**
040: *
041: */
042: private static final long serialVersionUID = -6506350696429732753L;
043: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
044: .getLogger(OrgCodeElement.class);
045: private static final String ATTRIBUTE_NAME = "value";
046: private boolean routeControl;
047: private String orgCode;
048:
049: public OrgCodeElement() {
050: LOG.debug("constructing . . .");
051: this .routeControl = false;
052: }
053:
054: public Element getXMLContent() {
055: LOG.debug("getXMLContent");
056:
057: //no eok representation of this fine grain of an element so if org is null
058: // or empty return an empty string
059: if (this .isEmpty()) {
060: LOG.debug("empty returning empty String");
061:
062: return null;
063: }
064:
065: //make the element
066: Element me = new Element(OrgCodeEOK.ORG_CD_TAG);
067: me.setAttribute(ATTRIBUTE_NAME, orgCode);
068:
069: LOG.debug("returning XMLContent = " + me.toString());
070:
071: return me;
072: }
073:
074: public void loadFromXMLContent(Element element, boolean allowBlank)
075: throws InvalidXmlException,
076: InconsistentDocElementStateException {
077: LOG.debug("loadFromXMLContent allowBlank = " + allowBlank);
078:
079: if (DocElementValidator.returnWithNoWorkDone(this , element,
080: allowBlank)) {
081: return;
082: }
083:
084: this .orgCode = element.getAttributeValue(ATTRIBUTE_NAME);
085: LOG.debug("element found setting value");
086: }
087:
088: public WorkflowServiceErrorImpl validate() {
089: LOG.debug("validate");
090:
091: if (this .isEmpty()) {
092: LOG.debug("invalid return DocElementError");
093:
094: return new WorkflowServiceErrorImpl("Org Code blank",
095: ServiceErrorConstants.ORG_BLANK);
096: }
097:
098: LOG.debug("valid returning null");
099:
100: return null;
101: }
102:
103: /**
104: * Tell whether the objects value property/properties have values
105: *
106: * @return true when object is empty
107: */
108: public boolean isEmpty() {
109: LOG.debug("isEmpty()");
110:
111: if ((this .orgCode == null) || this .orgCode.trim().equals("")) {
112: LOG.debug("empty");
113:
114: return true;
115: }
116:
117: LOG.debug("not empty");
118:
119: return false;
120: }
121:
122: /**
123: *
124: * @param orgCode An Org Code
125: */
126: public void setOrgCode(String orgCode) {
127: this .orgCode = orgCode;
128: }
129:
130: /**
131: *
132: * @return String or an Org Code
133: */
134: public String getOrgCode() {
135: return this .orgCode;
136: }
137:
138: public String getElementName() {
139: return OrgCodeEOK.ORG_CD_TAG;
140: }
141:
142: public void setRouteControl(boolean routeControl) {
143: this .routeControl = false;
144: }
145:
146: public boolean isRouteControl() {
147: return this .routeControl;
148: }
149: }
150:
151: /*
152: * Copyright 2003 The Trustees of Indiana University. All rights reserved.
153: *
154: * This file is part of the EDEN software package.
155: * For license information, see the LICENSE file in the top level directory
156: * of the EDEN source distribution.
157: */
|