Examples of BaseOBObject


Examples of org.openbravo.base.structure.BaseOBObject

            OBQuery<BaseOBObject> proQuery) {
        final String entityName = "PricingPriceList";
        final ArrayList<String> listVer = new ArrayList<String>();
        final Map<String, String> productIDandPriceSell = new HashMap<String, String>();
        // Get PriceList with priceListID
        final BaseOBObject bobo = OBDal.getInstance().get(entityName,
                priceListID);
        if (bobo == null) {
            throw new ResourceNotFoundException("No resource found for entity "
                    + entityName + " using id " + priceListID);
        }
        // Get PriceListVersions of the PriceList with priceListID
        final List<PriceListVersion> pricelvl = (List<PriceListVersion>) bobo
                .get("pricingPriceListVersionList");
        for (final PriceListVersion plv : pricelvl) {
            listVer.add(plv.getId());
        }
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

  @Override
  public Boolean isTransient(Object entity) {
    // special case, if the id is set but it was explicitly
    // set to new then return new
    if (entity instanceof BaseOBObject) {
      final BaseOBObject bob = (BaseOBObject) entity;
      if (bob.getId() != null && bob.isNewOBObject()) {
        return new Boolean(true);
      }
    }
    // let hibernate do the rest
    return null;
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

    if (!(entity instanceof OrganizationEnabled)) {
      return;
    }
    final Organization o1 = ((OrganizationEnabled) entity).getOrganization();
    final OBContext obContext = OBContext.getOBContext();
    final BaseOBObject bob = (BaseOBObject) entity;
    boolean isNew = bob.getId() == null || bob.isNewOBObject();

    // check if the organization of the current object has changed, if so
    // then
    // check all references
    if (!isNew) {
      for (int i = 0; i < currentState.length; i++) {
        if (propertyNames[i].equals(PROPERTY_ORGANIZATION)) {
          if (currentState[i] != previousState[i]) {
            isNew = true;
            break;
          }
        }
      }
    }

    for (int i = 0; i < currentState.length; i++) {
      // TODO maybe use equals
      if ((isNew || currentState[i] != previousState[i])
          && !(currentState[i] instanceof Organization)
          && (currentState[i] instanceof BaseOBObject || currentState[i] instanceof HibernateProxy)
          && currentState[i] instanceof OrganizationEnabled) {
        // get the organization from the current state
        final OrganizationEnabled oe = (OrganizationEnabled) currentState[i];
        final Organization o2 = oe.getOrganization();

        if (!obContext.getOrganizationStructureProvider(o1.getClient().getId()).isInNaturalTree(o1,
            o2)) {
          throw new OBSecurityException("Entity " + bob.getIdentifier() + " ("
              + bob.getEntityName() + ") with organization " + o1.getIdentifier()
              + " references an entity " + ((BaseOBObject) currentState[i]).getIdentifier()
              + " through its property " + propertyNames[i] + " but this referenced entity"
              + " belongs to an organization " + o2.getIdentifier()
              + " which is not part of the natural tree of " + o1.getIdentifier());
        }
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

  }

  // after flushing an object is not new anymore
  public void postFlush(Iterator entities) {
    while (entities.hasNext()) {
      final BaseOBObject bob = (BaseOBObject) entities.next();
      bob.setNewOBObject(false);
    }
  }
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

    public int compare(Object o1, Object o2) {
      if (!(o1 instanceof BaseOBObject) || !(o2 instanceof BaseOBObject)) {
        return 0;
      }
      final BaseOBObject bob1 = (BaseOBObject) o1;
      final BaseOBObject bob2 = (BaseOBObject) o2;
      if (!(bob1.getId() instanceof String) || !(bob2.getId() instanceof String)) {
        return 0;
      }
      try {
        final BigInteger bd1 = new BigInteger(bob1.getId().toString(), 32);
        final BigInteger bd2 = new BigInteger(bob2.getId().toString(), 32);
        return bd1.compareTo(bd2);
      } catch (final NumberFormatException n) {
        System.out.println("problem: " + n.getMessage());
        return 0;
      }
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

    public int compare(Object o1, Object o2) {
      if (!(o1 instanceof BaseOBObject) || !(o2 instanceof BaseOBObject)) {
        return 0;
      }
      final BaseOBObject bob1 = (BaseOBObject) o1;
      final BaseOBObject bob2 = (BaseOBObject) o2;
      final String bd1 = bob1.getId().toString();
      final String bd2 = bob2.getId().toString();
      return bd1.compareTo(bd2);
    }
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

        // so that the objects on which other depend are inserted first
        final List<BaseOBObject> toInsert = xec.getToInsert();
        int done = 0;
        final Set<BaseOBObject> inserted = new HashSet<BaseOBObject>();
        for (int i = toInsert.size() - 1; i > -1; i--) {
          final BaseOBObject ins = toInsert.get(i);
          // for (final BaseOBObject ins : toInsert) {
          insertObjectGraph(ins, inserted);
          ir.getInsertedObjects().add(ins);
          done++;
        }
        Check.isTrue(done == toInsert.size(),
            "Not all objects have been inserted, check for loop: " + done + "/" + toInsert.size());

        // flush to set the ids in the objects
        OBDal.getInstance().flush();

        // do the updates the other way around also
        done = 0;
        final List<BaseOBObject> toUpdate = xec.getToUpdate();
        for (int i = toUpdate.size() - 1; i > -1; i--) {
          final BaseOBObject upd = toUpdate.get(i);
          OBDal.getInstance().save(upd);
          ir.getUpdatedObjects().add(upd);
          done++;
        }
        Check.isTrue(done == toUpdate.size(),
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

        final String value = (String) objectToRepair.get(p.getName());
        // also ignore 0 as there is a business partner tree node with 0
        if (value != null && !value.equals("0")) {
          final Entity entity = PrimitiveReferenceHandler.getInstance()
              .getPrimitiveReferencedEntity(objectToRepair, p);
          final BaseOBObject referencedBob = (BaseOBObject) entityResolver.resolve(
              entity.getName(), value, true);
          if (referencedBob == null) {
            if (ir.getErrorMessages() == null) {
              ir.setErrorMessages("The object " + objectToRepair
                  + " references an object (entity: " + entity + ") with id " + value
                  + " which does not exist in the database or in the import set.");
            } else {
              ir.setErrorMessages(ir.getErrorMessages() + "\nThe object " + objectToRepair
                  + " references an object (entity: " + entity + ") with id " + value
                  + " which does not exist in the database or in the import set.");
            }
          } else if (!referencedBob.getId().equals(value)) {
            objectToRepair.set(p.getName(), referencedBob.getId());
          }
        }
      }
    }
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

          exc.setOutput(sw);
          exc.process(obq.list());
          xml = sw.toString();
        }
      } else {
        final BaseOBObject result = OBDal.getInstance().get(entityName, id);
        if (result == null) {
          throw new ResourceNotFoundException("No resource found for entity " + entityName
              + " using id " + id);
        }
        final StringWriter sw = new StringWriter();
View Full Code Here

Examples of org.openbravo.base.structure.BaseOBObject

    // it!
    final String[] segments = WebServiceUtil.getInstance().getSegments(path);
    if (segments.length == 2) {
      final String entityName = segments[0];
      final String id = segments[1];
      final BaseOBObject result = OBDal.getInstance().get(entityName, id);
      final String resIdentifier = result.getIdentifier();
      OBDal.getInstance().remove(result);

      final String resultXml = WebServiceUtil.getInstance().createResultXMLWithLogWarning(
          "Action performed successfully", "Removed business object " + resIdentifier, null);
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.