Changeset 295


Ignore:
Timestamp:
Jul 19, 2004, 10:18:16 AM (18 years ago)
Author:
per
Message:

Fixed drop to data connection + added annotation.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dist/proteios/conf/proteiosTest.xsd

    r294 r295  
    3434    </xs:complexType>
    3535  </xs:element>
    36   <!-- Report on an existing data connection tree -->
     36  <!-- Report on data connection tree, as seen rooted on element_type. -->
    3737  <xs:element name="Show">
    3838    <xs:complexType>
     
    5858      </xs:sequence>
    5959      <xs:attribute name="data_connection" type="xs:string" use="required"/>
    60       <!-- No filename => output to log file. -->
    6160      <xs:attribute name="file_name" type="xs:string" use="required"/>
    6261    </xs:complexType>
     
    6766      <xs:sequence>
    6867        <xs:element ref="Element"/>
     68        <!-- No parent => delete tree as seen rooted on element. -->
    6969        <xs:element ref="ParentElement" minOccurs="0"/>
    7070      </xs:sequence>
     
    9191  <xs:element name="Annotate">
    9292    <xs:complexType>
     93      <xs:sequence>
     94        <xs:element ref="Element"/>
     95      </xs:sequence>
    9396      <xs:attribute name="data_connection" type="xs:string" use="required"/>
    9497      <xs:attribute name="annotation" type="xs:string" use="required"/>
  • trunk/src/org/proteios/test/ProteiosTester.java

    r294 r295  
    5757* @navassoc - "<instantiate>" - org.proteios.test.DeleteSettings
    5858* @navassoc - "<instantiate>" - org.proteios.test.DropSettings
     59* @navassoc - "<instantiate>" - org.proteios.test.AnnotateSettings
    5960*
    6061* @author Per Gärdén.
     
    196197        break;
    197198      }
     199      case ANNOTATE:
     200      {
     201        if (qName.equals("Element"))
     202        {
     203          current_annotate.setElementType(attrs.getValue(attrs.getIndex("type")));
     204        }
     205        if (qName.equals("Attribute"))
     206        {
     207          current_annotate.setAttribute(attrs.getValue(attrs.getIndex("name")), attrs.getValue(attrs.getIndex("value")));
     208        }
     209      }
    198210      default:
    199211      {
     
    310322        else if (qName.equals("Annotate"))
    311323        {
     324          String data_connection = attrs.getValue(attrs.getIndex("data_connection"));
     325          DataConnection dc = (DataConnection) connections_map.get(data_connection);
     326          if (dc != null)
     327          {
     328            current_annotate = new AnnotateSettings();
     329            current_annotate.setDataConnection(dc);
     330            current_annotate.setAnnotation(attrs.getValue(attrs.getIndex("annotation")));
     331            // OK we're in business
     332            read = ANNOTATE;
     333          }
     334          else
     335          {
     336            // Not much annotate to be done, since there's no connection
     337            read = ERROR;
     338            if (warnings)
     339            {
     340              print(WARN, "Data Connection " + data_connection + " not found.");
     341            }
     342          }
    312343        }
    313344      }
     
    358389      }
    359390      // In any case get ready for next action
     391      read = NULL;
     392    }
     393    if (qName.equals("Annotate"))
     394    {
     395      if (read == ANNOTATE)
     396      {
     397        annotate(current_annotate);
     398      }
    360399      read = NULL;
    361400    }
     
    413452    {
    414453      core = new CMain();
    415       connections = core.getConnections();
     454      List connections = core.getConnections();
    416455      if ((connections != null) || (connections.size() < 1))
    417456      {
     
    672711    {
    673712      Element source_element = sc.getElement(drs.getSourceType(), source_attributes);
    674       Element target_element = tc.getElement(drs.getTargetType(), target_attributes);
    675       Element parent_element = tc.getElement(drs.getParentType(), parent_attributes);
     713      // Target may be null
     714      Element target_element = null;
     715      Element parent_element = null;
     716      String target_type = drs.getTargetType();
     717      String parent_type = drs.getParentType();
     718
     719      if (target_type != null)
     720      {
     721        target_element = tc.getElement(drs.getTargetType(), target_attributes);
     722      }
     723      if (parent_type != null)
     724      {
     725        parent_element = tc.getElement(drs.getParentType(), parent_attributes);
     726      }
     727
    676728      // Our target is an element
    677729      if (target_element != null)
     
    701753    }
    702754    catch (ImportException e)
     755    {
     756      print(ERROR, e.getMessage());
     757    }
     758  }
     759
     760
     761  /**
     762  * Annotate data from a built up AnnotateSettings object.
     763  *
     764  * @param ants the annotate settings.
     765  */
     766  private void annotate(AnnotateSettings ants)
     767  {
     768    DataConnection dc = ants.getDataConnection();
     769    Map attributes = ants.getAttributes();
     770    try
     771    {
     772      String element_type = ants.getElementType();
     773      Element element = dc.getElement(element_type, attributes);
     774      if (element != null)
     775      {
     776        element.setAnnotation(ants.getAnnotation());
     777      }
     778      else
     779      {
     780        if (warnings)
     781        {
     782          print(WARN, "Unable to locate specific " + element_type + " in " + dc.getName());
     783        }
     784      }
     785    }
     786    catch (CoreException e)
    703787    {
    704788      print(ERROR, e.getMessage());
     
    724808  /** Telling state machine that we're reading Drop and its subelements */
    725809  private static final int DROP = 7;
     810  private static final int ANNOTATE = 8;
    726811  /** Telling the state machine which kind of parent we're reading. */
    727812  private int read_elt = NULL;
    728813  /** Telling state machine that we're reading Parent element */
    729814  private static final int PARENT = 1;
    730   /** Telling state machine that we're reading target element */
    731   private static final int TARGET = 2;
     815  /** Telling state machine that we're reading target element */
     816  private static final int TARGET = 2;
    732817  /** Date format to use. */
    733818  private static SimpleDateFormat date_formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     
    740825  /** This is the connection to the core layer to test. */
    741826  private CMain core = null;
    742   /** Existing (database) connections from core layer. */
    743   private List connections;
    744827  /** A hash map of data connections for easy retrieval. */
    745828  private Map connections_map;
     
    750833  /** Intermittent drop action settings. */
    751834  private DropSettings current_drop;
     835  private AnnotateSettings current_annotate;
    752836}
Note: See TracChangeset for help on using the changeset viewer.