Package org.openbravo.base.model

Examples of org.openbravo.base.model.ModelProvider


   * Hibernate mapping is returned as a String.
   *
   * @return the generated Hibernate mapping (corresponds to what is found in a hbm.xml file)
   */
  public String generateMapping() {
    final ModelProvider mp = ModelProvider.getInstance();
    final StringBuilder sb = new StringBuilder();
    for (final Entity e : mp.getModel()) {
      final String entityMapping = generateMapping(e);
      sb.append(entityMapping);
    }
    final String mainTemplate = readFile(MAIN_TEMPLATE_FILE);
    final String result = mainTemplate.replace("content", sb.toString());
View Full Code Here


   *
   * @see ModelProvider
   */
  public void initialize() {

    final ModelProvider mp = ModelProvider.getInstance();
    final String userLevel = obContext.getUserLevel();

    // Don't use dal because otherwise we can end up in infinite loops
    final String qryStr = "select wa from " + WindowAccess.class.getName() + " wa where role.id='"
        + getRoleId() + "'";
    final Query qry = SessionHandler.getInstance().createQuery(qryStr);
    @SuppressWarnings("unchecked")
    final List<WindowAccess> was = qry.list();
    for (final WindowAccess wa : was) {
      final Window w = wa.getWindow();
      final boolean writeAccess = wa.isEditableField();
      // get the ttabs
      final String tfQryStr = "select t from " + Tab.class.getName() + " t where window.id='"
          + w.getId() + "'";
      @SuppressWarnings("unchecked")
      final List<Tab> ts = SessionHandler.getInstance().createQuery(tfQryStr).list();
      for (final Tab t : ts) {
        final String tableName = t.getTable().getDBTableName();
        final Entity e = mp.getEntityByTableName(tableName);
        if (e == null) { // happens for AD_Client_Info and views
          continue;
        }

        final String accessLevel = t.getTable().getDataAccessLevel();
        if (!hasCorrectAccessLevel(userLevel, accessLevel)) {
          continue;
        }

        if (writeAccess) {
          writableEntities.add(e);
          readableEntities.add(e);
        } else {
          readableEntities.add(e);
        }
      }
    }

    // and take into account table access
    final String tafQryStr = "select ta from " + TableAccess.class.getName()
        + " ta where role.id='" + getRoleId() + "'";
    @SuppressWarnings("unchecked")
    final List<TableAccess> tas = SessionHandler.getInstance().createQuery(tafQryStr).list();
    for (final TableAccess ta : tas) {
      final String accessLevel = ta.getTable().getDataAccessLevel();
      if (!hasCorrectAccessLevel(userLevel, accessLevel)) {
        continue;
      }

      final String tableName = ta.getTable().getName();
      final Entity e = mp.getEntityByTableName(tableName);

      if (ta.isExclude()) {
        readableEntities.remove(e);
        writableEntities.remove(e);
        nonReadableEntities.add(e);
View Full Code Here

TOP

Related Classes of org.openbravo.base.model.ModelProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.