Changeset 302


Ignore:
Timestamp:
Jul 21, 2004, 10:13:14 AM (19 years ago)
Author:
per
Message:

element_type (String) null test in DataConnection?.getElement.

Location:
trunk/src/org/proteios
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/proteios/core/DataConnection.java

    r274 r302  
    237237    Element retval = null;
    238238
    239     // Element does, of course, not have to be root, but this is how to fetch.
    240     List elts = getRootElements(element_type);
    241     boolean got_it = false;
    242 
    243     for (int i = 0; !(got_it) && (i < elts.size()); ++i)
    244     {
    245       // If the attribute map is empty, any element of the right type matches
    246       got_it = true;
    247       Element elt = (Element) elts.get(i);
    248       List entity_names = elt.getEntityNames();
    249       for (int j = 0; j < entity_names.size(); ++j)
    250       {
    251         String entity_name = (String) entity_names.get(j);
    252         String value = (String) attributes.get(entity_name);
    253         // Only if this is an attribute we are to check
    254         if (value != null)
    255         {
    256           got_it = (elt.getEntityValue(entity_name).toString().equals(value)) && got_it;
    257         }
    258       }
    259 
    260       if (got_it)
    261       {
    262         retval = elt;
    263       }
    264     }
     239    if (element_type != null)
     240    {
     241      // Element does, of course, not have to be root, but this is how to fetch.
     242      List elts = getRootElements(element_type);
     243      boolean got_it = false;
     244 
     245      for (int i = 0; !(got_it) && (i < elts.size()); ++i)
     246      {
     247        // If the attribute map is empty, any element of the right type matches
     248        got_it = true;
     249        Element elt = (Element) elts.get(i);
     250        List entity_names = elt.getEntityNames();
     251        for (int j = 0; j < entity_names.size(); ++j)
     252        {
     253          String entity_name = (String) entity_names.get(j);
     254          String value = (String) attributes.get(entity_name);
     255          // Only if this is an attribute we are to check
     256          if (value != null)
     257          {
     258            got_it = (elt.getEntityValue(entity_name).toString().equals(value)) && got_it;
     259          }
     260        }
     261 
     262        if (got_it)
     263        {
     264          retval = elt;
     265        }
     266      }
     267    }
    265268
    266269    return retval;
  • trunk/src/org/proteios/test/ProteiosTester.java

    r299 r302  
    634634
    635635      // If we're exporting from root, parent is null
    636       Element parent = null;
    637       String parent_type = exp.getParentType();
    638       if (parent_type != null)
    639       {
    640         attributes = exp.getParentAttributes();
    641         parent = dc.getElement(exp.getParentType(), attributes);
    642       }
     636      attributes = exp.getParentAttributes();
     637      Element parent = dc.getElement(exp.getParentType(), attributes);
    643638      exporter.doExport(element, parent, exp.getFileName());
    644639    }
     
    676671      attributes = dls.getParentAttributes();
    677672      // Parent might be null <=> we want to delete from the root
    678       Element parent = null;
    679       String parent_type = dls.getParentType();
    680       if (parent_type != null)
    681       {
    682         parent = dc.getElement(dls.getParentType(), attributes);
    683       }
     673      Element parent = dc.getElement(dls.getParentType(), attributes);
    684674      element.delete(parent);
    685675    }
     
    731721      List added_children = new ArrayList();
    732722      // Target may be null
    733       Element target_element = null;
    734       Element parent_element = null;
    735       String target_type = drs.getTargetType();
    736       String parent_type = drs.getParentType();
    737 
    738       if (target_type != null)
    739       {
    740         target_element = tc.getElement(drs.getTargetType(), target_attributes);
    741       }
    742       if (parent_type != null)
    743       {
    744         parent_element = tc.getElement(drs.getParentType(), parent_attributes);
    745       }
     723      Element target_element = tc.getElement(drs.getTargetType(), target_attributes);
     724      Element parent_element = tc.getElement(drs.getParentType(), parent_attributes);
    746725
    747726      // Our target is an element
Note: See TracChangeset for help on using the changeset viewer.