Package org.ofbiz.entity

Examples of org.ofbiz.entity.GenericPK


                element.appendChild(serializeSingle(iter.next(), document));
            }
            return element;
        } else if (object instanceof GenericPK) {
            // Do GenericEntity objects as a special case, use std XML import/export routines
            GenericPK value = (GenericPK) object;

            return value.makeXmlElement(document, "eepk-");
        } else if (object instanceof GenericValue) {
            GenericValue value = (GenericValue) object;

            return value.makeXmlElement(document, "eeval-");
        } else if (object instanceof Map<?, ?>) {
            // - Maps -
            String elementName = null;

            // these ARE order sensitive; for instance Properties extends Hashtable, so if Hashtable were first we would lose the Properties part
            if (object instanceof HashMap<?, ?>) {
                elementName = "map-HashMap";
            } else if (object instanceof Properties) {
                elementName = "map-Properties";
            } else if (object instanceof Hashtable<?, ?>) {
                elementName = "map-Hashtable";
            } else if (object instanceof WeakHashMap<?, ?>) {
                elementName = "map-WeakHashMap";
            } else if (object instanceof TreeMap<?, ?>) {
                elementName = "map-TreeMap";
            } else {
                // serialize as a simple Map implementation if nothing else applies, these will deserialize as a HashMap
                elementName = "map-Map";
            }

            Element element = document.createElement(elementName);
            Map<?,?> value = UtilGenerics.cast(object);
            Iterator<Map.Entry<?, ?>> iter = UtilGenerics.cast(value.entrySet().iterator());

            while (iter.hasNext()) {
                Map.Entry<?,?> entry = iter.next();

                Element entryElement = document.createElement("map-Entry");
View Full Code Here


                return new ArrayList();
            }

            // Get the account ID for this leadQueue.
            String leadQueueId = (String) filterValues.get("leadQueueId");
            GenericPK leadQueuePK = new GenericPK(delegator.getModelEntity(
                        "LeadQueue"));
            leadQueuePK.set("leadQueueId", leadQueueId);

            GenericValue leadQueueGV = null;

            try {
                leadQueueGV = delegator.findByPrimaryKey(leadQueuePK);
View Full Code Here

            Iterator eligibleEntityI = eligibleEntityL.iterator();

            while (eligibleEntityI.hasNext()) {
                GenericValue eligibleGV = (GenericValue) eligibleEntityI.next();
                GenericPK eligiblePK = eligibleGV.getPrimaryKey();
                Iterator eligiblePKFieldI = eligiblePK.getAllFields().entrySet()
                                                      .iterator();

                // Add an option to the available select box for this entity.
                // Example of value with 1 field in the key: "contactId:10341"
                // Example of value with 3 fields in the key: "displayObjectId:10021,displayTypeId:22320,displayAttribId:SIZE"
                displayHtml.append("        <OPTION VALUE=\"");

                int fieldCount = 0;
                StringBuffer keyStringBuf = new StringBuffer();

                while (eligiblePKFieldI.hasNext()) {
                    Map.Entry eligiblePKField = (Map.Entry) eligiblePKFieldI.next();

                    Debug.logVerbose("[displaySelectSection] eligiblePKField: " +
                            eligiblePKField.toString(), module);
                 

                    String eligiblePKFieldName = (String) eligiblePKField.getKey();

                    Debug.logVerbose("[displaySelectSection] eligiblePKFieldName: " +
                            eligiblePKFieldName.toString(), module);
  

                    String eligiblePKFieldValue = (String) eligiblePKField.getValue();

                    Debug.logVerbose("[displaySelectSection] eligiblePKFieldValue: " +
                            eligiblePKFieldValue.toString(), module);

                    if (++fieldCount > 1) {
                        keyStringBuf.append(",");
                    }

                    keyStringBuf.append(eligiblePKFieldName + ":" +
                        eligiblePKFieldValue);
                }

                // Append the key and the name.
                Vector listedEntityVector = new Vector();
                listedEntityVector.add(eligibleGV);

                String eligibleItemName = UIUtility.decodeEntityDisplayDef(getSelectNameDef(),
                        listedEntityVector, "");
                displayHtml.append(keyStringBuf.toString() + "\">" +
                    eligibleItemName + "\n");
            }

            displayHtml.append("       </SELECT>\n");
            displayHtml.append("      </TD>\n");

            // Display the arrow button.
            displayHtml.append("      <TD ALIGN=\"center\">\n");
            displayHtml.append("       <INPUT DISABLED TYPE=\"button\" NAME=\"" +
                getSectionName() + "SelectButton\" value=\"---\" " +
                "onClick=\"selectTransfer" + getSectionName() + "(this)\">\n");
            displayHtml.append("      </TD>\n");

            // Display the selected entities.
            displayHtml.append("      <TD>\n");
            displayHtml.append("       <SELECT STYLE=\"width: 100%\" " +
                "NAME=\"" + getSectionName() + "AssignedSel\" ID=\"" +
                getSectionName() +
                "AssignedSel\" SIZE=\"10\" onChange=\"handleAssignedChange" +
                getSectionName() + "()\">\n");

            Iterator selectedEntityGVI = selectedEntityGVC.iterator();

            while (selectedEntityGVI.hasNext()) {
                GenericValue selectedGV = (GenericValue) selectedEntityGVI.next();
                GenericPK selectedPK = (GenericPK) selectedGV.getPrimaryKey();
                Iterator selectedPKFieldI = selectedPK.getAllFields().entrySet()
                                                      .iterator();

                // Add an option to the available select box for this entity.
                // Example of value with 1 field in the key: "contactId:10341"
                // Example of value with 3 fields in the key: "displayObjectId:10021,displayTypeId:22320,displayAttribId:SIZE"
View Full Code Here

            GenericEntity dummyPK = (GenericEntity) context.get("dummyPK");
            if (Debug.infoOn()) Debug.logInfo("Got a clear cache line by dummyPK service call; entityName: " + dummyPK.getEntityName(), module);
            if (Debug.verboseOn()) Debug.logVerbose("Got a clear cache line by dummyPK service call; dummyPK: " + dummyPK, module);
            delegator.clearCacheLineFlexible(dummyPK, distribute);
        } else if (context.containsKey("primaryKey")) {
            GenericPK primaryKey = (GenericPK) context.get("primaryKey");
            if (Debug.infoOn()) Debug.logInfo("Got a clear cache line by primaryKey service call; entityName: " + primaryKey.getEntityName(), module);
            if (Debug.verboseOn()) Debug.logVerbose("Got a clear cache line by primaryKey service call; primaryKey: " + primaryKey, module);
            delegator.clearCacheLine(primaryKey, distribute);
        } else if (context.containsKey("condition")) {
            String entityName = (String) context.get("entityName");
            EntityCondition condition = (EntityCondition) context.get("condition");
View Full Code Here

     *
     * @return
     */
    public int delete(UserInfo userInfo, GenericDelegator delegator,
        String originatingEntityName, GenericValue entityGV) {
        GenericPK entityPK = null;
        String entityName = null;
        String entityKeyString = entityGV.getPrimaryKey().toString();

        Debug.logVerbose("Removing entities dependent on " + entityKeyString, module);

View Full Code Here

    public List findOneRelated(UserInfo userInfo, GenericDelegator delegator,
        GenericValue entityGV, String relationTitle, String relatedEntityName) {
        // Find instances of a particular entity related to the current entity.  This will normally be called by
        // the deleteAllRelated method of a descendant of this class.

        GenericPK entityPK = null;

        //    String entityName = entityGV.getEntityName();
        String entityKeyString = entityGV.getPrimaryKey().toString();

        List relatedGVL = null;
View Full Code Here

     */
    protected int deleteOneSelect(ModelEntity primaryModelEntity,
        HashMap removeMap, UserInfo userInfo, GenericDelegator delegator) {

        try {
            GenericPK removePK = new GenericPK(primaryModelEntity, removeMap);

            try {
                delegator.removeByPrimaryKey(removePK);
            } catch (Exception e2) {
                Debug.logError("Error removing entity using primary key map " +
View Full Code Here

  }

  public boolean convert ( String leadId )
  {
    DataMatrix dataMatrix = DataMatrix.fillFromDB(delegator, userInfo, uiWebScreenSection, leadEventProcessor,
                                        new GenericPK( delegator.getModelEntity("Lead"), UtilMisc.toMap("leadId", leadId) ));

    return convert( delegator, dataMatrix, userInfo, uiCache );

  }
View Full Code Here

      DataInfo dataInfo = (DataInfo) dataMatrixMap.get("ACCOUNT.AccountHeader");
      GenericEventProcessor eventProcessor = new AccountEventProcessor();
     
        if ( (accountId != null) && ( accountId.length() > 0) )
      {
        dataInfo.retrieveFromDB(userInfo, eventProcessor, new GenericPK( delegator.getModelEntity("Account"), UtilMisc.toMap("accountId", accountId)));
        dataInfo.processUpdate( userInfo, delegator, eventProcessor );     
      }
      else
      {
        dataInfo.loadData(userInfo, eventProcessor);
        dataInfo.processInsert( userInfo, delegator, eventProcessor )
      }
     
      GenericValue accountGV = dataInfo.dataMatrix.getCurrentBuffer().getGenericValue(0, "Account", false);
      accountId = accountGV.getString("accountId");
        accountName = accountGV.getString("accountName");
      }

      if ( getCreateContact())
      {
        DataInfo dataInfo = (DataInfo) dataMatrixMap.get("CONTACT.ContactHeader");
        GenericEventProcessor eventProcessor = new ContactEventProcessor();
       
        if ( (contactId != null) && (contactId.length() > 0))
        {
          dataInfo.retrieveFromDB(userInfo, eventProcessor, new GenericPK( delegator.getModelEntity("Contact"), UtilMisc.toMap("contactId", contactId)));
          if ( hasAccountInfo )
          {
              GenericValue contactGV = dataInfo.dataMatrix.getCurrentBuffer().getGenericValue(0, "Contact", false);
              String accountIdOrig = contactGV.getString("accountId");
              if ( ( accountIdOrig == null ) || ( accountIdOrig.length() < 1) )
View Full Code Here

            throw new IllegalArgumentException("Error in entity-one definition, cannot specify select-field elements when use-cache is set to true");
        }

        try {
            GenericValue valueOut = null;
            GenericPK entityPK = delegator.makePK(modelEntity.getEntityName(), entityContext);

            // make sure we have a full primary key, if any field is null then just log a warning and return null instead of blowing up
            if (entityPK.containsPrimaryKey(true)) {
                if (useCache) {
                    valueOut = delegator.findOne(entityPK.getEntityName(), entityPK, true);
                } else {
                    if (fieldsToSelect != null) {
                        valueOut = delegator.findByPrimaryKeyPartial(entityPK, fieldsToSelect);
                    } else {
                        valueOut = delegator.findOne(entityPK.getEntityName(), entityPK, false);
                    }
                }
            } else {
                if (Debug.infoOn()) Debug.logInfo("Returning null because found incomplete primary key in find: " + entityPK, module);
            }
View Full Code Here

TOP

Related Classes of org.ofbiz.entity.GenericPK

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.