Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  * either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
 package org.dbflute.bhv.core.command;
 
 import java.util.List;
 

Author(s):
jflute
 
 public abstract class AbstractListEntityCommand extends AbstractBehaviorCommand<int[]> {
 
     // ===================================================================================
     //                                                                           Attribute
     //                                                                           =========
     
The type of entity. (Required)
 
     protected Class<? extends Entity_entityType;

    
The instance of condition-bean. (Required)
 
     protected List<? extends Entity_entityList;
 
     // ===================================================================================
     //                                                                   Basic Information
     //                                                                   =================
     public Class<?> getCommandReturnType() {
         return int[].class;
     }
 
     // ===================================================================================
     //                                                                  Detail Information
     //                                                                  ==================
     public boolean isConditionBean() {
         return false;
     }
 
     public boolean isOutsideSql() {
         return false;
     }
 
     public boolean isProcedure() {
         return false;
     }
 
     public boolean isSelect() {
         return false;
     }
 
     public boolean isSelectCount() {
         return false;
     }
 
     public boolean isSelectCursor() {
         return false;
     }
 
     public boolean isInsert() {
         return false// as default
     }
 
     public boolean isUpdate() {
         return false// as default
     }
 
     public boolean isDelete() {
         return false// as default
     }
 
     // ===================================================================================
     //                                                                             Factory
     //                                                                             =======
     // -----------------------------------------------------
     //                                          BeanMetaData
     //                                          ------------
     protected TnBeanMetaData createBeanMetaData() {
     }
 
    // ===================================================================================
    //                                                                    Process Callback
    //                                                                    ================
    public void beforeGettingSqlExecution() {
    }
    public void afterExecuting() {
    }
    // ===================================================================================
    //                                                               SqlExecution Handling
    //                                                               =====================
    public String buildSqlExecutionKey() {
        assertStatus("buildSqlExecutionKey");
        final String entityName = DfTypeUtil.toClassTitle();
        return  + ":" + getCommandName() + "(List<" + entityName + ">)";
    }
    public Object[] getSqlExecutionArgument() {
        assertStatus("getSqlExecutionArgument");
        return doGetSqlExecutionArgument();
    }
    protected abstract Object[] doGetSqlExecutionArgument();
    // ===================================================================================
    //                                                                Argument Information
    //                                                                ====================
    public ConditionBean getConditionBean() {
        return null;
    }
    public String getOutsideSqlPath() {
        return null;
    }
    public String getParameterBean() {
        return null;
    }
        return null;
    }
    // ===================================================================================
    //                                                                       Assist Helper
    //                                                                       =============
    
Find DB meta.
Basically this method should be called when initializing only.

Returns:
DB meta. (NullAllowed: If the entity does not its DB meta)
    protected DBMeta findDBMeta() {
        // /- - - - - - - - - - - - - - - - - - - - - - - - - - - - 
        // Cannot use the handler of DBMeta instance
        // because the customize-entity is contained to find here.
        // - - - - - - - - - -/
        //DBMetaInstanceHandler.findDBMeta(_tableDbName);
        final Class<?> beanType = ;
        if (beanType == null) {
            return null;
        }
        if (!Entity.class.isAssignableFrom(beanType)) {
            return null;
        }
        final Entity entity;
        try {
            entity = (EntitybeanType.newInstance();
        } catch (InstantiationException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
        return entity.asDBMeta();
    }

    
Get persistent property names.
Basically this method should be called when initializing only.

Parameters:
bmd The bean meta data. (NotNull)
Returns:
Persistent property names. (NotNull)
    protected String[] getPersistentPropertyNames(TnBeanMetaData bmd) {
        final DBMeta dbmeta = findDBMeta();
        if (dbmeta != null) {
            final List<ColumnInfocolumnInfoList = dbmeta.getColumnInfoList();
            final List<StringpropertyNameList = new ArrayList<String>();
            for (ColumnInfo columnInfo : columnInfoList) {
                propertyNameList.add(columnInfo.getPropertyName());
            }
            return propertyNameList.toArray(new String[] {});
        } else {
            // when the entity does not have its DB meta.
            return createNonOrderedPropertyNames(bmd);
        }
    }
        final List<StringpropertyNameList = new ArrayList<String>();
        final List<TnPropertyTypeptList = bmd.getPropertyTypeList();
        for (TnPropertyType pt : ptList) {
            if (pt.isPersistent()) {
                propertyNameList.add(pt.getPropertyName());
            }
        }
        return propertyNameList.toArray(new String[propertyNameList.size()]);
    }
    // ===================================================================================
    //                                                                       Assert Helper
    //                                                                       =============
    protected void assertStatus(String methodName) {
        assertBasicProperty(methodName);
        assertComponentProperty(methodName);
        if ( == null) {
            throw new IllegalStateException(buildAssertMessage("_entityType"methodName));
        }
        if ( == null) {
            throw new IllegalStateException(buildAssertMessage("_entityList"methodName));
        }
    }
    // ===================================================================================
    //                                                                            Accessor
    //                                                                            ========
    public void setEntityType(Class<? extends EntityentityType) {
         = entityType;
    }
    public void setEntityList(List<? extends EntityentityList) {
         = entityList;
    }
New to GrepCode? Check out our FAQ X