001package org.andromda.cartridges.hibernate.metafacades; 002 003import org.andromda.metafacades.uml.ClassifierFacade; 004 005/** 006 * MetafacadeLogic implementation for 007 * org.andromda.cartridges.hibernate.metafacades.HibernateFinderMethodArgument. 008 * 009 * @see org.andromda.cartridges.hibernate.metafacades.HibernateFinderMethodArgument 010 */ 011public class HibernateFinderMethodArgumentLogicImpl 012 extends HibernateFinderMethodArgumentLogic 013{ 014 private static final long serialVersionUID = 34L; 015 // ---------------- constructor ------------------------------- 016 /** 017 * @param metaObject 018 * @param context 019 */ 020 public HibernateFinderMethodArgumentLogicImpl( 021 Object metaObject, 022 String context) 023 { 024 super(metaObject, context); 025 } 026 027 /** 028 * Defines if specific setters methods will be created for primitive types 029 * and dates 030 */ 031 private static final String USE_SPECIALIZED_SETTERS = "hibernateQueryUseSpecializedSetters"; 032 033 /** 034 * @see org.andromda.cartridges.hibernate.metafacades.HibernateFinderMethodArgument#getQueryArgumentNameSetter() 035 */ 036 @Override 037 protected String handleGetQueryArgumentNameSetter() 038 { 039 StringBuilder setterName = new StringBuilder(); 040 boolean specializedSetters = 041 Boolean.valueOf(String.valueOf(this.getConfiguredProperty(USE_SPECIALIZED_SETTERS))).booleanValue(); 042 ClassifierFacade classifier = this.getType(); 043 if (classifier != null) 044 { 045 if (specializedSetters) 046 { 047 if (classifier.isPrimitive()) 048 { 049 setterName.append("set").append(classifier.getWrapperName().replaceAll("(.)*\\.", "")); 050 } 051 else if (classifier.isDateType() || classifier.isStringType()) 052 { 053 setterName.append("set").append(classifier.getName()); 054 } 055 else 056 { 057 setterName.append("setParameter"); 058 } 059 } 060 else 061 { 062 setterName.append("setParameter"); 063 } 064 if (classifier.isCollectionType()) 065 { 066 setterName.append("List"); 067 } 068 } 069 return setterName.toString(); 070 } 071}