Package org.openbravo.model.ad.access

Examples of org.openbravo.model.ad.access.User


        role.setName(getNewName() + "_" + role.getName());
      } else {
        role.setName(replace(role.getName(), originalName));
      }
    } else if (bob instanceof User) {
      final User user = (User) bob;
      if (user.getUsername() == null) {
        return;
      }
      if (user.getUsername().indexOf(originalName) == -1) {
        user.setUsername(getNewName() + "_" + user.getUsername());
      } else {
        user.setUsername(replace(user.getUsername(), originalName));
      }
    } else if (bob instanceof Organization) {
      final Organization org = (Organization) bob;
      if (org.getName().indexOf(originalName) == -1) {
        org.setName(getNewName() + "_" + org.getName());
View Full Code Here


  }

  // sets the context by reading all user information
  public boolean initialize(String userId, String roleId, String clientId, String orgId) {
    String localClientId = clientId;
    final User u = SessionHandler.getInstance().find(User.class, userId);
    if (u == null) {
      return false;
    }
    setInitialized(false);
    setInAdministratorMode(true);
    try {
      setUser(u);
      Hibernate.initialize(getUser().getClient());
      Hibernate.initialize(getUser().getOrganization());
      Hibernate.initialize(getUser().getDefaultOrganization());
      Hibernate.initialize(getUser().getDefaultWarehouse());
      Hibernate.initialize(getUser().getDefaultClient());
      Hibernate.initialize(getUser().getDefaultRole());
      Hibernate.initialize(getUser().getDefaultLanguage());

      organizationStructureProviderByClient = new HashMap<String, OrganizationStructureProvider>();

      // first take the passed role, if any
      // now check if the default role is active, if not another one needs
      // to be
      // selected.
      if (roleId != null) {
        final Role r = getOne(Role.class, "select r from " + Role.class.getName() + " r where "
            + " r." + Role.PROPERTY_ID + "='" + roleId + "'");
        setRole(r);
      } else if (getUser().getDefaultRole() != null && getUser().getDefaultRole().isActive()) {
        setRole(getUser().getDefaultRole());
      } else {

        final UserRoles ur = getOne(UserRoles.class, "select ur from " + UserRoles.class.getName()
            + " ur where " + " ur." + UserRoles.PROPERTY_USERCONTACT + "." + User.PROPERTY_ID
            + "='" + u.getId() + "' and ur." + UserRoles.PROPERTY_ACTIVE + "='Y' and ur."
            + UserRoles.PROPERTY_ROLE + "." + Role.PROPERTY_ACTIVE + "='Y' order by ur."
            + UserRoles.PROPERTY_ROLE + "." + Role.PROPERTY_ID + " asc", false);
        if (ur == null) {
          throw new OBSecurityException(
              "Your user is not assigned to a Role and it is required to login into Openbravo. Ask the Security Administrator");
View Full Code Here

  }

  // set created/createdby and the client and organization
  private void onNew(Traceable t, String[] propertyNames, Object[] currentState) {
    final OBContext obContext = OBContext.getOBContext();
    final User currentUser = obContext.getUser();
    log
        .debug("OBEvent for new object " + t.getClass().getName() + " user "
            + currentUser.getName());

    Client client = null;
    Organization org = null;
    if (t instanceof ClientEnabled || t instanceof OrganizationEnabled) {
      // reread the client and organization
View Full Code Here

  }

  // Sets the updated/updatedby
  // TODO: can the client/organization change?
  protected void onUpdate(Traceable t, String[] propertyNames, Object[] currentState) {
    final User currentUser = OBContext.getOBContext().getUser();
    log.debug("OBEvent for updated object " + t.getClass().getName() + " user "
        + currentUser.getName());
    for (int i = 0; i < propertyNames.length; i++) {
      if (PROPERTY_UPDATED.equals(propertyNames[i])) {
        currentState[i] = new Date();
      }
      if (PROPERTY_UPDATEDBY.equals(propertyNames[i])) {
View Full Code Here

TOP

Related Classes of org.openbravo.model.ad.access.User

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.