001: package org.andromda.cartridges.jsf.metafacades;
002:
003: import org.andromda.cartridges.jsf.metafacades.JSFControllerOperationLogic;
004: import org.andromda.cartridges.jsf.JSFGlobals;
005: import org.andromda.metafacades.uml.ModelElementFacade;
006: import org.apache.commons.lang.ObjectUtils;
007: import org.apache.commons.lang.StringUtils;
008:
009: /**
010: * MetafacadeLogic implementation for org.andromda.cartridges.jsf.metafacades.JSFControllerOperation.
011: *
012: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation
013: */
014: public class JSFControllerOperationLogicImpl extends
015: JSFControllerOperationLogic {
016:
017: public JSFControllerOperationLogicImpl(Object metaObject,
018: String context) {
019: super (metaObject, context);
020: }
021:
022: /**
023: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation#getFormName()
024: */
025: protected java.lang.String handleGetFormName() {
026: final String pattern = ObjectUtils.toString(this
027: .getConfiguredProperty(JSFGlobals.FORM_PATTERN));
028: return pattern.replaceFirst("\\{0\\}", StringUtils
029: .capitalize(this .getName()));
030: }
031:
032: /**
033: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation#getFullyQualifiedFormName()
034: */
035: protected java.lang.String handleGetFullyQualifiedFormName() {
036: final StringBuffer fullyQualifiedName = new StringBuffer();
037: final String packageName = this .getPackageName();
038: if (StringUtils.isNotBlank(packageName)) {
039: fullyQualifiedName.append(packageName + '.');
040: }
041: return fullyQualifiedName.append(
042: StringUtils.capitalize(this .getFormName())).toString();
043: }
044:
045: /**
046: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation#getFullyQualifiedFormPath()
047: */
048: protected java.lang.String handleGetFullyQualifiedFormPath() {
049: return this .getFullyQualifiedFormName().replace('.', '/');
050: }
051:
052: /**
053: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation#getFormCall()
054: */
055: protected String handleGetFormCall() {
056: final StringBuffer call = new StringBuffer();
057: call.append(this .getName());
058: call.append("(");
059: if (!this .getFormFields().isEmpty()) {
060: call.append("form");
061: }
062: call.append(")");
063: return call.toString();
064: }
065:
066: /**
067: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation#getmplementationFormSignature()
068: */
069: protected String handleGetImplementationFormSignature() {
070: return this .getFormSignature(false);
071: }
072:
073: /**
074: * @see org.andromda.cartridges.jsf.metafacades.JSFControllerOperation#getFormSignature()
075: */
076: protected String handleGetFormSignature() {
077: return this .getFormSignature(true);
078: }
079:
080: /**
081: * Constructs the signature that takes the form for this operation.
082: *
083: * @param isAbstract whether or not the signature is abstract.
084: * @return the appropriate signature.
085: */
086: private final String getFormSignature(boolean isAbstract) {
087: final StringBuffer signature = new StringBuffer();
088: signature.append(this .getVisibility() + ' ');
089: if (isAbstract) {
090: signature.append("abstract ");
091: }
092: final ModelElementFacade returnType = this .getReturnType();
093: signature.append(returnType != null ? returnType
094: .getFullyQualifiedName() : null);
095: signature.append(" " + this .getName() + "(");
096: if (!this .getFormFields().isEmpty()) {
097: signature.append(this .getFormName() + " form");
098: }
099: signature.append(")");
100: return signature.toString();
101: }
102: }
|