001package org.andromda.cartridges.jbpm.metafacades; 002 003import org.andromda.metafacades.uml.ActivityGraphFacade; 004import org.andromda.metafacades.uml.StateMachineFacade; 005import org.andromda.metafacades.uml.UseCaseFacade; 006import org.andromda.utils.StringUtilsHelper; 007import org.apache.commons.lang.StringUtils; 008 009/** 010 * MetafacadeLogic implementation for org.andromda.cartridges.jbpm.metafacades.JBpmPseudostate. 011 * 012 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostate 013 */ 014public class JBpmPseudostateLogicImpl 015 extends JBpmPseudostateLogic 016{ 017 private static final long serialVersionUID = 34L; 018 /** 019 * @param metaObject 020 * @param context 021 */ 022 public JBpmPseudostateLogicImpl (Object metaObject, String context) 023 { 024 super (metaObject, context); 025 } 026 027 /** 028 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#getName() 029 */ 030 public String getName() 031 { 032 String name = super.getName(); 033 if (StringUtils.isBlank(name)) 034 { 035 name = "start"; 036 } 037 return name; 038 } 039 040 /** 041 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#handleGetClassName() 042 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostate#getClassName() 043 */ 044 protected String handleGetClassName() 045 { 046 return StringUtilsHelper.upperCamelCaseName(getName()); 047 } 048 049 /** 050 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#handleGetSwimlane() 051 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostate#getSwimlane() 052 */ 053 protected Object handleGetSwimlane() 054 { 055 return this.getPartition(); 056 } 057 058 /** 059 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#handleGetDecisionHandlerPackageName() 060 */ 061 protected String handleGetDecisionHandlerPackageName() 062 { 063 String packageName = null; 064 065 final StateMachineFacade stateMachine = this.getStateMachine(); 066 if (stateMachine instanceof ActivityGraphFacade) 067 { 068 final UseCaseFacade useCase = ((ActivityGraphFacade)stateMachine).getUseCase(); 069 if (useCase != null) 070 { 071 packageName = useCase.getPackageName(); 072 } 073 } 074 075 return packageName; 076 } 077 078 /** 079 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#handleGetDecisionHandlerFullPath() 080 */ 081 protected String handleGetDecisionHandlerFullPath() 082 { 083 return StringUtils.replace(this.getClazz(), ".", "/"); 084 } 085 086 /** 087 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#handleGetDecisionHandlerClassName() 088 */ 089 protected String handleGetDecisionHandlerClassName() 090 { 091 return StringUtilsHelper.upperCamelCaseName(this.getName()); 092 } 093 094 /** 095 * @see org.andromda.cartridges.jbpm.metafacades.JBpmPseudostateLogic#handleGetClazz() 096 */ 097 protected String handleGetClazz() 098 { 099 String decisionHandlerClass = null; 100 101 if (this.isDecisionPoint()) 102 { 103 final StringBuilder clazzBuffer = new StringBuilder(); 104 if (StringUtils.isNotBlank(this.getDecisionHandlerPackageName())) 105 { 106 clazzBuffer.append(this.getDecisionHandlerPackageName()); 107 clazzBuffer.append('.'); 108 } 109 clazzBuffer.append(this.getDecisionHandlerClassName()); 110 decisionHandlerClass = clazzBuffer.toString(); 111 } 112 113 return decisionHandlerClass; 114 } 115}