Пример #1
0
  /**
   * Performs additional indexing based on the view type associated with the view instance. The
   * {@code ViewTypeService} associated with the view type name on the instance is invoked to
   * retrieve the parameter key/value pairs from the configured property values, which are then used
   * to build up an index used to key the entry
   *
   * @param propertyValues - property values configured on the view bean definition
   * @param id - id (or bean name if id was not set) for the view
   */
  protected void indexViewForType(PropertyValues propertyValues, String id) {
    String viewTypeName = ViewModelUtils.getStringValFromPVs(propertyValues, "viewTypeName");
    if (StringUtils.isBlank(viewTypeName)) {
      return;
    }

    UifConstants.ViewType viewType = ViewType.valueOf(viewTypeName);

    ViewTypeService typeService =
        KRADServiceLocatorWeb.getViewService().getViewTypeService(viewType);
    if (typeService == null) {
      // don't do any further indexing
      return;
    }

    // invoke type service to retrieve it parameter name/value pairs
    Map<String, String> typeParameters =
        typeService.getParametersFromViewConfiguration(propertyValues);

    // build the index string from the parameters
    String index = buildTypeIndex(typeParameters);

    // get the index for the type and add the view entry
    ViewTypeDictionaryIndex typeIndex = getTypeIndex(viewType);

    typeIndex.put(index, id);
  }
Пример #2
0
  /**
   * Gets all {@code View} prototypes configured for the given view type name
   *
   * @param viewTypeName - view type name to retrieve
   * @return List<View> view prototypes with the given type name, or empty list
   */
  public List<View> getViewsForType(ViewType viewTypeName) {
    List<View> typeViews = new ArrayList<View>();

    // get view ids for the type
    if (viewEntriesByType.containsKey(viewTypeName.name())) {
      ViewTypeDictionaryIndex typeIndex = viewEntriesByType.get(viewTypeName.name());
      for (Entry<String, String> typeEntry : typeIndex.getViewIndex().entrySet()) {
        View typeView = ddBeans.getBean(typeEntry.getValue(), View.class);
        typeViews.add(typeView);
      }
    } else {
      throw new DataDictionaryException("Unable to find view index for type: " + viewTypeName);
    }

    return typeViews;
  }