Package de.fu_berlin.inf.dpp.whiteboard.sxe.records

Examples of de.fu_berlin.inf.dpp.whiteboard.sxe.records.NodeRecord


  @Override
  public IRecord getIRecord(DocumentRecord document)
      throws MissingRecordException {
    NodeType nodeType = NodeType.fromString(getString(RecordEntry.TYPE));

    NodeRecord record;
    String tmp, rid;

    ISXERecordFactory factory = document.getController().getRecordFactory();

    String parentRid = getString(RecordEntry.PARENT);
    if (parentRid == null) {
      if (!document.isEmpty())
        throw new MalformedRecordException(
            "Received non-root record without parent: "
                + getString(RecordEntry.RID));
    }

    String name = getString(RecordEntry.NAME);
    String ns = getString(RecordEntry.NS);

    switch (nodeType) {
    case ATTR:
      String chdata = getString(RecordEntry.CHDATA);
      AttributeRecord attribute = factory.createAttributeRecord(document,
          ns, name, chdata);
      if (chdata != null)
        attribute.setChdata(chdata);
      record = attribute;
      break;
    case ELEMENT:
      if (parentRid == null)
        record = factory.createRoot(document);
      else
        record = factory.createElementRecord(document, ns, name);
      break;
    default:
      throw new RuntimeException("Unknown node type " + getRecordType());
    }

    rid = getString(RecordEntry.RID);
    record.setRid(rid);

    tmp = getString(RecordEntry.VERSION);
    if (tmp != null)
      record.setVersion(Integer.valueOf(tmp));
    else
      record.setVersion(0);

    if (parentRid != null)
      record.setParent(document.getElementRecordById(parentRid));

    Float pw = getFloat(RecordEntry.PRIMARY_WEIGHT);
    if (pw == null)
      pw = 0f;
    record.setPrimaryWeight(pw);

    tmp = getString(RecordEntry.NAME);
    if (tmp != null)
      record.setName(tmp);

    tmp = getString(RecordEntry.NS);
    if (tmp != null)
      record.setNs(tmp);

    // if no creator specified set sender as creator
    // TODO maybe creator tag is obsolete
    tmp = getString(RecordEntry.CREATOR);
    if (tmp != null)
      record.setCreator(tmp);
    else
      record.setCreator(getSender());

    tmp = getString(RecordEntry.LAST_MODIFIED_BY);
    if (tmp != null)
      record.setLastModifiedBy(tmp);

    record.setSender(getSender());

    return record;
  }
View Full Code Here


    tmp = getString(RecordEntry.TARGET);
    if (tmp == null)
      throw new MalformedRecordException("target rid missing");

    NodeRecord target = document.getRecordById(tmp);
    int version = getInt(RecordEntry.VERSION);

    ElementRecord parent = null;

    tmp = getString(RecordEntry.PARENT);
View Full Code Here

  }

  @Override
  public boolean isAlreadyApplied(DocumentRecord document)
      throws MissingRecordException {
    NodeRecord record = document.getRecordById(getTargetRid());
    IRecord setRecord = getIRecord(document);
    return record.getSetRecords().contains(setRecord);
  }
View Full Code Here

TOP

Related Classes of de.fu_berlin.inf.dpp.whiteboard.sxe.records.NodeRecord

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.