org.broadleafcommerce.openadmin.web.controller.entity
Class BroadleafAdminAbstractEntityController

java.lang.Object
  extended by org.broadleafcommerce.common.web.controller.BroadleafAbstractController
      extended by org.broadleafcommerce.openadmin.web.controller.BroadleafAdminAbstractController
          extended by org.broadleafcommerce.openadmin.web.controller.entity.BroadleafAdminAbstractEntityController
Direct Known Subclasses:
BroadleafAdminBasicEntityController, BroadleafAdminDeclaredSectionAbstractEntityController

public abstract class BroadleafAdminAbstractEntityController
extends BroadleafAdminAbstractController

An abstract controller that provides sensible operations for admin actions. It is very dynamic in nature and does not have any custom-tailored logic for any one given screen.

Author:
Andre Azzolini (apazzolini)

Field Summary
protected  EntityConfiguration entityConfiguration
           
protected  EntityFormValidator entityValidator
           
protected  FormBuilderService formService
           
protected  AdminEntityService service
           
 
Fields inherited from class org.broadleafcommerce.openadmin.web.controller.BroadleafAdminAbstractController
adminNavigationService, currentSectionKey
 
Constructor Summary
BroadleafAdminAbstractEntityController()
           
 
Method Summary
 String addCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, String collectionField, EntityForm entityForm)
          Adds the requested collection item
 String addEntity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, EntityForm entityForm, org.springframework.validation.BindingResult result)
           
protected  void attachSectionSpecificInfo(PersistencePackageRequest ppr)
           
protected  List<ClassTree> getAddEntityTypes(ClassTree classTree)
           
protected  EntityForm getBlankDynamicFieldTemplateForm(DynamicEntityFormInfo info)
           
protected  String getClassNameForSection(String sectionKey)
           
 String getCollectionFieldRecords(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, String collectionField, CriteriaForm criteriaForm)
          Returns the records for a given collectionField filtered by a particular criteria
protected  ListGrid getCollectionListGrid(ClassMetadata mainMetadata, Entity entity, Property collectionProperty, FilterAndSortCriteria[] criteria, String sectionKey)
          Convenience method for obtaining a ListGrid DTO object for a collection.
protected  String getDefaultEntityType()
           
protected  EntityForm getDynamicFieldTemplateForm(DynamicEntityFormInfo info, String entityId)
           
 String getDynamicForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, DynamicEntityFormInfo info)
          Returns a partial representing a dynamic form.
protected  String[] getSectionCustomCriteria()
           
protected  PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName)
           
protected  PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName, FilterAndSortCriteria[] filterAndSortCriteria)
           
 void initBinder(org.springframework.web.bind.WebDataBinder binder)
           
 String removeCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, String collectionField, String collectionItemId)
          Removes the requested collection item Note that the request must contain a parameter called "key" when attempting to remove a collection item from a map collection.
 String removeEntity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, EntityForm entityForm, org.springframework.validation.BindingResult result)
          Attempts to remove the given entity.
 String saveEntity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, EntityForm entityForm, org.springframework.validation.BindingResult result, org.springframework.web.servlet.mvc.support.RedirectAttributes ra)
          Attempts to save the given entity.
protected  void setModelAttributes(org.springframework.ui.Model model, String sectionKey)
           
 String showAddCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, String collectionField)
          Shows the modal dialog that is used to add an item to a given collection.
 String showSelectCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String collectionField, CriteriaForm criteriaForm)
          Shows the modal dialog that is used to select a "to-one" collection item.
 String showUpdateCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, String collectionField, String collectionItemId)
           
 String updateCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id, String collectionField, String collectionItemId, EntityForm entityForm)
          Updates the specified collection item
 String viewAddEntityForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String entityType)
          Renders the modal form that is used to add a new parent level entity.
 String viewCollectionItemDetails(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String collectionField, String id)
          Shows the modal popup for the current selected "to-one" field.
 String viewEntityForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, String id)
          Renders the main entity form for the specified entity
 String viewEntityList(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String sectionKey, CriteriaForm criteriaForm)
          Renders the main entity listing for the specified class, which is based on the current sectionKey with some optional criteria.
 
Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
getContextPath, isAjaxRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

service

protected AdminEntityService service

formService

protected FormBuilderService formService

entityConfiguration

protected EntityConfiguration entityConfiguration

entityValidator

protected EntityFormValidator entityValidator
Constructor Detail

BroadleafAdminAbstractEntityController

public BroadleafAdminAbstractEntityController()
Method Detail

viewEntityList

public String viewEntityList(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             org.springframework.ui.Model model,
                             String sectionKey,
                             CriteriaForm criteriaForm)
                      throws Exception
Renders the main entity listing for the specified class, which is based on the current sectionKey with some optional criteria.

Parameters:
request -
response -
model -
sectionKey -
criteriaForm - criteria from the frontend; can be null
Returns:
the return view path
Throws:
Exception

viewAddEntityForm

public String viewAddEntityForm(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                org.springframework.ui.Model model,
                                String sectionKey,
                                String entityType)
                         throws Exception
Renders the modal form that is used to add a new parent level entity. Note that this form cannot render any subcollections as operations on those collections require the parent level entity to first be saved and have and id. Once the entity is initially saved, we will redirect the user to the normal manage entity screen where they can then perform operations on sub collections.

Parameters:
request -
response -
model -
sectionKey -
entityType -
Returns:
the return view path
Throws:
Exception

addEntity

public String addEntity(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        org.springframework.ui.Model model,
                        String sectionKey,
                        EntityForm entityForm,
                        org.springframework.validation.BindingResult result)
                 throws Exception
Throws:
Exception

viewEntityForm

public String viewEntityForm(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             org.springframework.ui.Model model,
                             String sectionKey,
                             String id)
                      throws Exception
Renders the main entity form for the specified entity

Parameters:
request -
response -
model -
sectionKey -
id -
modal - - whether or not to show the entity in a read-only modal
Returns:
the return view path
Throws:
Exception

saveEntity

public String saveEntity(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         org.springframework.ui.Model model,
                         String sectionKey,
                         String id,
                         EntityForm entityForm,
                         org.springframework.validation.BindingResult result,
                         org.springframework.web.servlet.mvc.support.RedirectAttributes ra)
                  throws Exception
Attempts to save the given entity. If validation is unsuccessful, it will re-render the entity form with error fields highlighted. On a successful save, it will refresh the entity page.

Parameters:
request -
response -
model -
sectionKey -
id -
entityForm -
result -
Returns:
the return view path
Throws:
Exception

removeEntity

public String removeEntity(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           org.springframework.ui.Model model,
                           String sectionKey,
                           String id,
                           EntityForm entityForm,
                           org.springframework.validation.BindingResult result)
                    throws Exception
Attempts to remove the given entity.

Parameters:
request -
response -
model -
sectionKey -
id -
Returns:
the return view path
Throws:
Exception

getDynamicForm

public String getDynamicForm(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             org.springframework.ui.Model model,
                             String sectionKey,
                             DynamicEntityFormInfo info)
                      throws Exception
Returns a partial representing a dynamic form. An example of this is the dynamic fields that render on structured content, which are determined by the currently selected structured content type. This method is typically only invoked through Javascript and used to replace the current dynamic form with the one for the newly selected type.

Parameters:
request -
response -
model -
id -
propertyName -
propertyTypeId -
criteriaName -
ceilingClassName -
Returns:
the return view path
Throws:
Exception

getCollectionFieldRecords

public String getCollectionFieldRecords(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        org.springframework.ui.Model model,
                                        String sectionKey,
                                        String id,
                                        String collectionField,
                                        CriteriaForm criteriaForm)
                                 throws Exception
Returns the records for a given collectionField filtered by a particular criteria

Parameters:
request -
response -
model -
sectionKey -
collectionField -
criteriaForm -
Returns:
Throws:
Exception

showSelectCollectionItem

public String showSelectCollectionItem(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       org.springframework.ui.Model model,
                                       String sectionKey,
                                       String collectionField,
                                       CriteriaForm criteriaForm)
                                throws Exception
Shows the modal dialog that is used to select a "to-one" collection item. For example, this could be used to show a list of categories for the ManyToOne field "defaultCategory" in Product.

Parameters:
request -
response -
model -
sectionKey -
collectionField -
Returns:
the return view path
Throws:
Exception

viewCollectionItemDetails

public String viewCollectionItemDetails(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        org.springframework.ui.Model model,
                                        String sectionKey,
                                        String collectionField,
                                        String id)
                                 throws Exception
Shows the modal popup for the current selected "to-one" field. For instance, if you are viewing a list of products then this method is invoked when a user clicks on the name of the default category field.

Parameters:
request -
response -
model -
sectionKey -
collectionField -
id -
Returns:
Throws:
Exception

showAddCollectionItem

public String showAddCollectionItem(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    org.springframework.ui.Model model,
                                    String sectionKey,
                                    String id,
                                    String collectionField)
                             throws Exception
Shows the modal dialog that is used to add an item to a given collection. There are several possible outcomes of this call depending on the type of the specified collection field.

showUpdateCollectionItem

public String showUpdateCollectionItem(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       org.springframework.ui.Model model,
                                       String sectionKey,
                                       String id,
                                       String collectionField,
                                       String collectionItemId)
                                throws Exception
Throws:
Exception

addCollectionItem

public String addCollectionItem(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                org.springframework.ui.Model model,
                                String sectionKey,
                                String id,
                                String collectionField,
                                EntityForm entityForm)
                         throws Exception
Adds the requested collection item

Parameters:
request -
response -
model -
sectionKey -
id -
collectionField -
entityForm -
Returns:
the return view path
Throws:
Exception

updateCollectionItem

public String updateCollectionItem(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   org.springframework.ui.Model model,
                                   String sectionKey,
                                   String id,
                                   String collectionField,
                                   String collectionItemId,
                                   EntityForm entityForm)
                            throws Exception
Updates the specified collection item

Parameters:
request -
response -
model -
sectionKey -
id -
collectionField -
entityForm -
Returns:
the return view path
Throws:
Exception

removeCollectionItem

public String removeCollectionItem(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   org.springframework.ui.Model model,
                                   String sectionKey,
                                   String id,
                                   String collectionField,
                                   String collectionItemId)
                            throws Exception
Removes the requested collection item Note that the request must contain a parameter called "key" when attempting to remove a collection item from a map collection.

Parameters:
request -
response -
model -
sectionKey -
id -
collectionField -
collectionItemId -
Returns:
the return view path
Throws:
Exception

initBinder

public void initBinder(org.springframework.web.bind.WebDataBinder binder)

getAddEntityTypes

protected List<ClassTree> getAddEntityTypes(ClassTree classTree)

getDefaultEntityType

protected String getDefaultEntityType()

getBlankDynamicFieldTemplateForm

protected EntityForm getBlankDynamicFieldTemplateForm(DynamicEntityFormInfo info)
                                               throws ServiceException,
                                                      com.gwtincubator.security.exception.ApplicationSecurityException
Throws:
ServiceException
com.gwtincubator.security.exception.ApplicationSecurityException

getDynamicFieldTemplateForm

protected EntityForm getDynamicFieldTemplateForm(DynamicEntityFormInfo info,
                                                 String entityId)
                                          throws ServiceException,
                                                 com.gwtincubator.security.exception.ApplicationSecurityException
Throws:
ServiceException
com.gwtincubator.security.exception.ApplicationSecurityException

getCollectionListGrid

protected ListGrid getCollectionListGrid(ClassMetadata mainMetadata,
                                         Entity entity,
                                         Property collectionProperty,
                                         FilterAndSortCriteria[] criteria,
                                         String sectionKey)
                                  throws ServiceException,
                                         com.gwtincubator.security.exception.ApplicationSecurityException
Convenience method for obtaining a ListGrid DTO object for a collection. Note that if no criteria is available, then this should be null (or empty)

Parameters:
mainMetadata - class metadata for the root entity that this collectionProperty relates to
id - foreign key from the root entity for collectionProperty
collectionProperty - property that this collection should be based on from the root entity
criteria - criteria to filter the subcollection list by, can be null
sectionKey - the current main section key
Returns:
Throws:
ServiceException
com.gwtincubator.security.exception.ApplicationSecurityException

getClassNameForSection

protected String getClassNameForSection(String sectionKey)

setModelAttributes

protected void setModelAttributes(org.springframework.ui.Model model,
                                  String sectionKey)

getSectionPersistencePackageRequest

protected PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName)

getSectionPersistencePackageRequest

protected PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName,
                                                                        FilterAndSortCriteria[] filterAndSortCriteria)

getSectionCustomCriteria

protected String[] getSectionCustomCriteria()

attachSectionSpecificInfo

protected void attachSectionSpecificInfo(PersistencePackageRequest ppr)


Copyright © 2013. All Rights Reserved.