Tabnine Logo
ViewRepository
Code IndexAdd Tabnine to your IDE (free)

How to use
ViewRepository
in
com.haulmont.cuba.core.global

Best Java code snippets using com.haulmont.cuba.core.global.ViewRepository (Showing top 20 results out of 315)

origin: com.haulmont.cuba/cuba-core

@Override
public View getView(Class<? extends Entity> entityClass, String name) {
  try {
    return viewRepository.getView(entityClass, name);
  } catch (ViewNotFoundException e) {
    return null;
  }
}
origin: com.haulmont.cuba/cuba-rest-api

public String getView(String entityName, String viewName) {
  MetaClass metaClass = restControllersUtils.getMetaClass(entityName);
  View view = viewRepository.findView(metaClass, viewName);
  if (view == null) {
    throw new RestAPIException("View not found",
        String.format("View %s for metaClass %s not found", viewName, entityName),
        HttpStatus.NOT_FOUND);
  }
  return viewSerializationAPI.toJson(view);
}
origin: com.haulmont.cuba/cuba-rest-api

  public String getAllViewsForMetaClass(String entityName) {
    MetaClass metaClass = restControllersUtils.getMetaClass(entityName);
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    List<String> jsonViews = new ArrayList<>();
    for (String viewName : viewRepository.getViewNames(metaClass)) {
      View view = viewRepository.getView(metaClass, viewName);
      jsonViews.add(viewSerializationAPI.toJson(view));
    }
    sb.append(Joiner.on(",").join(jsonViews));
    sb.append("]");
    return sb.toString();
  }
}
origin: com.haulmont.addon.dashboard/dashboard-web

protected void loadViewNames(MetaClass metaClass) {
  List<String> viewNames = new ArrayList<>(metadata.getViewRepository().getViewNames(metaClass));
  viewLookup.setOptionsList(viewNames);
}
origin: com.haulmont.addon.admintools/cuba-at-gui

  protected void setEntityViewsLookup() {
    List<String> views = new LinkedList<>();
    views.add(View.MINIMAL);
    views.add(View.LOCAL);
    views.addAll(metadata.getViewRepository().getViewNames((MetaClass) entitiesMetaClasses.getValue()));

    entityViews.setOptionsList(views);
    entityViews.setValue(View.LOCAL);
  }
}
origin: com.haulmont.cuba/cuba-gui

protected void loadView(Element element, Class<Entity> entityClass, InstanceContainer<Entity> container) {
  String viewName = element.attributeValue("view");
  if (viewName != null) {
    container.setView(viewRepository.getView(entityClass, viewName));
  }
}
origin: com.haulmont.cuba/cuba-web

protected Entity loadEntityInstance(EntityLoadInfo info) {
  if (info.isNewEntity()) {
    return metadata.create(info.getMetaClass());
  }
  //noinspection unchecked
  LoadContext<Entity> ctx = new LoadContext(info.getMetaClass()).setId(info.getId());
  if (info.getViewName() != null) {
    View view = viewRepository.findView(info.getMetaClass(), info.getViewName());
    if (view != null) {
      ctx.setView(view);
    } else {
      log.warn("Unable to find view \"{}\" for entity \"{}\"", info.getViewName(), info.getMetaClass());
    }
  }
  Entity entity;
  try {
    entity = dataService.load(ctx);
  } catch (Exception e) {
    log.warn("Unable to load item: {}", info, e);
    return null;
  }
  return entity;
}
origin: com.haulmont.reports/reports-gui

protected void refreshViewNames(@Nullable ReportInputParameter reportInputParameter) {
  if (reportInputParameter != null) {
    if (StringUtils.isNotBlank(reportInputParameter.getEntityMetaClass())) {
      MetaClass parameterMetaClass = metadata.getClass(reportInputParameter.getEntityMetaClass());
      Collection<String> viewNames = metadata.getViewRepository().getViewNames(parameterMetaClass);
      Map<String, Object> views = new HashMap<>();
      for (String viewName : viewNames) {
        views.put(viewName, viewName);
      }
      views.put(View.LOCAL, View.LOCAL);
      views.put(View.MINIMAL, View.MINIMAL);
      viewNameLookup.setOptionsMap(views);
      return;
    }
  }
  viewNameLookup.setOptionsMap(new HashMap<>());
}
origin: com.haulmont.cuba/cuba-core

/**
 * Fetch instance by view name.
 */
public void fetch(Entity instance, String viewName) {
  if (viewName == null)
    return;
  View view = viewRepository.getView(instance.getClass(), viewName);
  fetch(instance, view, new HashMap<>(), false);
}
origin: com.haulmont.cuba/cuba-gui

  );
view = metadata.getViewRepository().findView(getMetaClass(), property.getView().getName());
origin: com.haulmont.cuba/cuba-gui

public void setView(String viewName) {
  this.view = metadata.getViewRepository().getView(metaClass, viewName);
}
origin: com.haulmont.reports/reports-core

View reportEditView = viewRepository.findView(savedReport.getMetaClass(), "report.edit");
return dataManager.reload(savedReport, reportEditView, savedReport.getMetaClass(), true);
origin: com.haulmont.cuba/cuba-core

/**
 * Fetch instance by view name.
 *
 * @param optimizeForDetached if true, detached objects encountered in the graph will be first checked whether all
 *                            required attributes are already loaded, and reloaded only when needed.
 *                            If the argument is false, all detached objects are reloaded anyway.
 */
public void fetch(Entity instance, String viewName, boolean optimizeForDetached) {
  if (viewName == null)
    return;
  View view = viewRepository.getView(instance.getClass(), viewName);
  fetch(instance, view, new HashMap<>(), optimizeForDetached);
}
origin: com.haulmont.cuba/cuba-client

@Override
public <E extends Entity> E reload(E entity, String viewName) {
  Objects.requireNonNull(viewName, "viewName is null");
  return reload(entity, metadata.getViewRepository().getView(entity.getClass(), viewName));
}
origin: com.haulmont.cuba/cuba-core

@Override
public TypedQuery<T> addViewName(String viewName) {
  if (resultClass == null)
    throw new IllegalStateException("resultClass is null");
  addView(metadata.getViewRepository().getView(resultClass, viewName));
  return this;
}
origin: com.haulmont.cuba/cuba-core

@Override
public TypedQuery<T> setViewName(String viewName) {
  if (resultClass == null)
    throw new IllegalStateException("resultClass is null");
  setView(metadata.getViewRepository().getView(resultClass, viewName));
  return this;
}
origin: com.haulmont.cuba/cuba-rest-api

/**
 * Finds a view for a given metaClass. Throws a RestAPIException if view not found
 */
public View getView(MetaClass metaClass, String viewName) {
  try {
    return viewRepository.getView(metaClass, viewName);
  } catch (ViewNotFoundException e) {
    throw new RestAPIException("View not found",
        String.format("View %s for entity %s not found", viewName, metaClass.getName()),
        HttpStatus.BAD_REQUEST);
  }
}
origin: com.haulmont.cuba/cuba-core

@Override
public <E extends Entity> E reload(E entity, String viewName) {
  Objects.requireNonNull(viewName, "viewName is null");
  return reload(entity, metadata.getViewRepository().getView(entity.getClass(), viewName));
}
origin: com.haulmont.cuba/cuba-core

@Nullable
@Override
public <T extends Entity<K>, K> T find(Class<T> entityClass, K id, String... viewNames) {
  View[] viewArray = new View[viewNames.length];
  for (int i = 0; i < viewNames.length; i++) {
    viewArray[i] = metadata.getViewRepository().getView(entityClass, viewNames[i]);
  }
  return find(entityClass, id, viewArray);
}
origin: com.haulmont.cuba/cuba-core

protected View getViewFromContext(CommitContext context, Entity entity) {
  View view = context.getViews().get(entity);
  if (view == null) {
    view = viewRepository.getView(entity.getClass(), View.LOCAL);
  }
  return isAuthorizationRequired(context) ? attributeSecurity.createRestrictedView(view) : view;
}
com.haulmont.cuba.core.globalViewRepository

Javadoc

Represents a repository of View objects, accessible by names.
Repository contains all views defined in XML and deployed at runtime.

Most used methods

  • getView
    Get View for an entity.
  • findView
    Searches for a View for an entity.
  • getViewNames
    Returns names of views defined for the entityClass

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getExternalFilesDir (Context)
  • onCreateOptionsMenu (Activity)
  • setScale (BigDecimal)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JList (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now