コード例 #1
0
  public void addOrUpdateLink(long srcId, short srcPort, long dstId, short dstPort, LinkType type) {
    boolean flag1 = false, flag2 = false;

    Link link = new Link(srcId, srcPort, dstId, dstPort);
    addPortToSwitch(srcId, srcPort);
    addPortToSwitch(dstId, dstPort);

    addLinkToStructure(switchPortLinks, link);

    if (type.equals(LinkType.MULTIHOP_LINK)) {
      addLinkToStructure(portBroadcastDomainLinks, link);
      flag1 = removeLinkFromStructure(tunnelLinks, link);
      flag2 = removeLinkFromStructure(directLinks, link);
      dtLinksUpdated = flag1 || flag2;
    } else if (type.equals(LinkType.TUNNEL)) {
      addLinkToStructure(tunnelLinks, link);
      removeLinkFromStructure(portBroadcastDomainLinks, link);
      removeLinkFromStructure(directLinks, link);
      dtLinksUpdated = true;
    } else if (type.equals(LinkType.DIRECT_LINK)) {
      addLinkToStructure(directLinks, link);
      removeLinkFromStructure(tunnelLinks, link);
      removeLinkFromStructure(portBroadcastDomainLinks, link);
      dtLinksUpdated = true;
    }
    linksUpdated = true;
  }
コード例 #2
0
ファイル: LinkModel.java プロジェクト: amirhakim/Ref
 /**
  * Gets the links for an owning entity
  *
  * @param ownerbean the owning entity
  * @return the links
  * @throws Exception the exception
  */
 public Collection<Link> getLinks(KeyedEntity<?> ownerbean) throws Exception {
   LinkDB adb = (LinkDB) db_;
   if (ownerbean == null) return new ArrayList<Link>();
   LinkType type = typemap.get(ownerbean.getClass());
   if (type == null) return new ArrayList<Link>();
   return adb.getLinks(ownerbean.getKey(), type.toString());
 }
コード例 #3
0
ファイル: LinkModel.java プロジェクト: amirhakim/Ref
  /**
   * Adds a link.
   *
   * @param owner the owning Entity
   * @param pathIn the path (url, filepath, or entity key)
   * @param linkType the link type
   * @throws Exception the exception
   */
  public void addLink(KeyedEntity<?> owner, String pathIn, LinkType linkType) throws Exception {
    String path = pathIn;
    if (owner == null) {
      Errmsg.getErrorHandler().notice(Resource.getResourceString("att_owner_null"));
      return;
    }

    if (linkType == LinkType.ATTACHMENT) {

      String atfolder = attachmentFolder();
      if (atfolder == null) throw new Exception("attachments not supported");

      // need to copy file and create new path
      File orig = new File(path);
      String fname = orig.getName();
      String newpath = atfolder + "/" + fname;

      int i = 1;
      while (true) {
        File newfile = new File(newpath);
        if (!newfile.exists()) break;

        fname = Integer.toString(i) + orig.getName();
        newpath = atfolder + "/" + fname;
        i++;
      }

      copyFile(path, newpath);
      path = fname;
    }

    Link at = newLink();
    at.setKey(-1);
    at.setOwnerKey(new Integer(owner.getKey()));
    LinkType type = typemap.get(owner.getClass());
    if (type == null) throw new Exception("illegal link owner type");
    at.setOwnerType(type.toString());
    at.setPath(path);
    at.setLinkType(linkType.toString());
    saveLink(at);

    // * modification for backtrace/2way link

    if (linkType == LinkType.ADDRESS
        || linkType == LinkType.APPOINTMENT
        || linkType == LinkType.PROJECT
        || linkType == LinkType.TASK) {
      Link at2way = newLink();
      at2way.setKey(-1);
      at2way.setOwnerKey(new Integer(at.getPath()));
      at2way.setOwnerType(at.getLinkType());
      at2way.setPath(at.getOwnerKey().toString());
      at2way.setLinkType(at.getOwnerType());
      saveLink(at2way);
    }
    // end of modification

  }
コード例 #4
0
ファイル: LinkModel.java プロジェクト: amirhakim/Ref
 /**
  * Move links from one object to another
  *
  * @param oldOwner the old owner
  * @param newOwner the new owner
  * @throws Exception the exception
  */
 public void moveLinks(KeyedEntity<?> oldOwner, KeyedEntity<?> newOwner) throws Exception {
   Collection<Link> atts = getLinks(oldOwner);
   Iterator<Link> it = atts.iterator();
   while (it.hasNext()) {
     Link at = it.next();
     at.setOwnerKey(new Integer(newOwner.getKey()));
     LinkType type = typemap.get(newOwner.getClass());
     if (type == null) throw new Exception("illegal link owner type");
     at.setOwnerType(type.toString());
     db_.updateObj(at);
   }
 }
コード例 #5
0
 private void completeLinks(PostsType posts) {
   for (PostType post : posts.getPost()) {
     if (post.getLinks() != null) {
       for (LinkType link : post.getLinks().getLink()) {
         if (!link.getUrl().matches("^http://.*")) {
           link.setUrl(
               "http://"
                   + post.getSource()
                   + link.getUrl().substring(link.getUrl().matches("^/.*") ? 1 : 0));
         }
       }
     }
   }
 }
コード例 #6
0
  public LinkToEditorAction() {
    super("linkToEditor", Action.AS_DROP_DOWN_MENU);

    List<IContributionItem> items = new ArrayList<IContributionItem>();
    for (LinkType linkType : LinkType.values()) {
      LinkTypeAction action = new LinkTypeAction(linkType);
      IContributionItem item = new ActionContributionItem(action);
      items.add(item);
    }
    setMenuCreator(new LinkToEditorMenuCreator(items));
  }
コード例 #7
0
ファイル: ScenarioRestorer.java プロジェクト: relteq/sirius
  private com.relteq.sirius.jaxb.Link restoreLink(Links db_link) throws TorqueException {
    com.relteq.sirius.jaxb.Link link = factory.createLink();
    link.setId(id2str(db_link.getId()));

    // begin node
    com.relteq.sirius.jaxb.Begin begin = factory.createBegin();
    begin.setNodeId(id2str(db_link.getBegNodeId()));
    link.setBegin(begin);

    // end node
    com.relteq.sirius.jaxb.End end = factory.createEnd();
    end.setNodeId(id2str(db_link.getEndNodeId()));
    link.setEnd(end);

    link.setRoads(restoreRoads(db_link));
    // TODO link.setDynamics();
    link.setShape(db_link.getGeom()); // TODO revise: geometry -> shape

    LinkLanes db_llanes = LinkLanesPeer.retrieveByPK(db_link.getId(), db_link.getNetworkId());
    link.setLanes(db_llanes.getLanes());

    @SuppressWarnings("unchecked")
    List<LinkLaneOffset> db_lloffset_l = db_link.getLinkLaneOffsets();
    if (!db_lloffset_l.isEmpty()) {
      link.setLaneOffset(db_lloffset_l.get(0).getDisplayLaneOffset());
      if (1 < db_lloffset_l.size())
        logger.warn(
            "Found " + db_lloffset_l.size() + " lane offsets for link[id=" + db_link.getId() + "]");
    }

    link.setLength(db_link.getLength());

    LinkType db_linktype = LinkTypePeer.retrieveByPK(db_link.getId(), db_link.getNetworkId());
    link.setType(db_linktype.getType());

    link.setInSynch(db_link.getInSynch());
    return link;
  }
コード例 #8
0
ファイル: LinkModel.java プロジェクト: amirhakim/Ref
  /**
   * Delete links that target a given entity
   *
   * @param target the target entity object
   * @throws Exception the exception
   */
  public void deleteLinksToEntity(Object target) throws Exception {

    if (target == null) return;

    LinkType type = typemap.get(target.getClass());
    if (type == null) return;

    Collection<Link> links = getLinks();
    for (Link link : links) {
      if (link.getLinkType().equals(type.toString())) {
        if ((type == LinkType.MEMO && ((Memo) target).getMemoName().equals(link.getPath()))
            || (type == LinkType.CHECKLIST
                && ((CheckList) target).getCheckListName().equals(link.getPath()))) {
          delete(link);
        } else if (target instanceof KeyedEntity<?>) {
          int key = ((KeyedEntity<?>) target).getKey();
          if (link.getPath().equals(Integer.toString(key))) {
            delete(link);
          }
        }
      }
    }
  }
コード例 #9
0
 public String toSystem(LinkType code) {
   return code.getSystem();
 }
コード例 #10
0
ファイル: LinkInfo.java プロジェクト: suraj-raturi/pinpoint
 public String getLinktype() {
   return linkType.getName();
 }