001package org.andromda.cartridges.ejb3.metafacades; 002 003import java.util.ArrayList; 004import java.util.List; 005import org.andromda.cartridges.ejb3.EJB3Profile; 006import org.apache.commons.lang.BooleanUtils; 007import org.apache.commons.lang.StringUtils; 008 009/** 010 * MetafacadeLogic implementation for org.andromda.cartridges.ejb3.metafacades.EJB3SessionAttributeFacade. 011 * 012 * @see EJB3SessionAttributeFacade 013 */ 014public class EJB3SessionAttributeFacadeLogicImpl 015 extends EJB3SessionAttributeFacadeLogic 016{ 017 private static final long serialVersionUID = 34L; 018 // ---------------- constructor ------------------------------- 019 020 /** 021 * @param metaObject 022 * @param context 023 */ 024 public EJB3SessionAttributeFacadeLogicImpl(final Object metaObject, final String context) 025 { 026 super (metaObject, context); 027 } 028 029 // ---------------- methods ------------------------------- 030 031 /** 032 * @see EJB3SessionAttributeFacade#getTransactionType() 033 */ 034 @Override 035 protected String handleGetTransactionType() 036 { 037 return (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_TRANSACTION_TYPE, true); 038 } 039 040 /** 041 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamAttribute() 042 */ 043 @Override 044 protected boolean handleIsSeamAttribute() 045 { 046 boolean isSeamAttribute = false; 047 if (this.isSeamBijectionIn() || 048 this.isSeamBijectionLogger() || 049 this.isSeamBijectionOut() || 050 this.isSeamBijectionRequestParameter() || 051 this.isSeamDataModel() || 052 this.isSeamDataModelSelection()) 053 { 054 isSeamAttribute = true; 055 } 056 return isSeamAttribute; 057 } 058 059 /** 060 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionIn() 061 */ 062 @Override 063 protected boolean handleIsSeamBijectionIn() 064 { 065 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_IN); 066 } 067 068 /** 069 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionInParameters() 070 */ 071 @Override 072 protected String handleGetSeamBijectionInParameters() 073 { 074 List<String> parameters = new ArrayList<String>(); 075 if (!super.isRequired()) 076 { 077 parameters.add("required = false"); 078 } 079 else 080 { 081 if (BooleanUtils.toBoolean( 082 (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_IN_CREATE, true))) 083 { 084 parameters.add("create = true"); 085 } 086 } 087 String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_IN_VALUE, true); 088 if (StringUtils.isNotBlank(value)) 089 { 090 parameters.add("value = \"" + value + '\"'); 091 } 092 093 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 094 } 095 096 /** 097 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionOut() 098 */ 099 @Override 100 protected boolean handleIsSeamBijectionOut() 101 { 102 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_OUT); 103 } 104 105 /** 106 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionOutParameters() 107 */ 108 @Override 109 protected String handleGetSeamBijectionOutParameters() 110 { 111 List<String> parameters = new ArrayList<String>(); 112 if (!super.isRequired()) 113 { 114 parameters.add("required = false"); 115 } 116 117 String scope = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_OUT_SCOPE_TYPE, true); 118 if (StringUtils.isNotBlank(scope)) 119 { 120 parameters.add("scope = org.jboss.seam.ScopeType." + scope); 121 } 122 123 String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_OUT_VALUE, true); 124 if (StringUtils.isNotBlank(value)) 125 { 126 parameters.add("value = \"" + value + '\"'); 127 } 128 129 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 130 } 131 132 /** 133 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamValidationValid() 134 */ 135 @Override 136 protected boolean handleIsSeamValidationValid() 137 { 138 boolean isSeamValidComponent = false; 139 if (this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_VALIDATION_VALID)) 140 { 141 isSeamValidComponent = true; 142 } 143 return isSeamValidComponent; 144 } 145 146 /** 147 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamDataModel() 148 */ 149 @Override 150 protected boolean handleIsSeamDataModel() 151 { 152 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_DATA_DATAMODEL); 153 } 154 155 /** 156 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamDataModelParameters() 157 */ 158 @Override 159 protected String handleGetSeamDataModelParameters() 160 { 161 List<String> parameters = new ArrayList<String>(); 162 String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_VALUE, true); 163 if (StringUtils.isNotBlank(value)) 164 { 165 parameters.add("value = \"" + value + '\"'); 166 } 167 String scope = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_SCOPE_TYPE, true); 168 if (StringUtils.isNotBlank(scope)) 169 { 170 parameters.add("scope = org.jboss.seam.ScopeType." + scope); 171 } 172 173 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 174 } 175 176 /** 177 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamDataModelSelection() 178 */ 179 @Override 180 protected boolean handleIsSeamDataModelSelection() 181 { 182 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_DATA_DATAMODEL_SELECTION); 183 } 184 185 /** 186 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamDataModelSelectionParameters() 187 */ 188 @Override 189 protected String handleGetSeamDataModelSelectionParameters() 190 { 191 List<String> parameters = new ArrayList<String>(); 192 String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_SELECTION_VALUE, true); 193 if (StringUtils.isNotBlank(value)) 194 { 195 parameters.add("value = \"" + value + '\"'); 196 } 197 198 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 199 } 200 201 /** 202 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamDataModelSelection() 203 */ 204 @Override 205 protected boolean handleIsSeamDataModelSelectionIndex() 206 { 207 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_DATA_DATAMODEL_SELECTION_INDEX); 208 } 209 210 /** 211 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamDataModelSelectionIndexParameters() 212 */ 213 @Override 214 protected String handleGetSeamDataModelSelectionIndexParameters() 215 { 216 List<String> parameters = new ArrayList<String>(); 217 String value = (String)this.findTaggedValue( 218 EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_SELECTION_INDEX_VALUE, true); 219 if (StringUtils.isNotBlank(value)) 220 { 221 parameters.add("value = \"" + value + '\"'); 222 } 223 224 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 225 } 226 227 /** 228 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionLogger() 229 */ 230 @Override 231 protected boolean handleIsSeamBijectionLogger() 232 { 233 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_LOGGER); 234 } 235 236 /** 237 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionLoggerParameters() 238 */ 239 @Override 240 protected String handleGetSeamBijectionLoggerParameters() 241 { 242 if (!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_LOGGER)) 243 { 244 return null; 245 } 246 List<String> parameters = new ArrayList<String>(); 247 String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_LOGGER_VALUE, true); 248 if (StringUtils.isNotBlank(value)) 249 { 250 parameters.add("value = \"" + value + '\"'); 251 } 252 253 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 254 } 255 256 /** 257 * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionRequestParameter() 258 */ 259 @Override 260 protected boolean handleIsSeamBijectionRequestParameter() 261 { 262 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_REQUEST_PARAMETER); 263 } 264 265 /** 266 * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionRequestParameterParameters() 267 */ 268 @Override 269 protected String handleGetSeamBijectionRequestParameterParameters() 270 { 271 List<String> parameters = new ArrayList<String>(); 272 String value = (String)this.findTaggedValue( 273 EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_REQUEST_PARAMETER_VALUE, true); 274 if (StringUtils.isNotBlank(value)) 275 { 276 parameters.add("value = \"" + value + '\"'); 277 } 278 279 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters); 280 } 281}