コード例 #1
0
  @Published()
  @GET
  @Path("/jconf/{jconfid: [0-9]+}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPublicationsByJconfID(
      @DefaultValue("-1") @PathParam("jconfid") Integer jconfid,
      @DefaultValue("-1") @QueryParam("startYear") Integer startYear,
      @DefaultValue("-1") @QueryParam("endYear") Integer endYear,
      @DefaultValue("0") @QueryParam("limStart") Integer limStart,
      @DefaultValue("-1") @QueryParam("limEnd") Integer limEnd) {

    // Check permission.
    String denyReason = support.checkPermission(request, uriInfo);
    if (null != denyReason) {
      return denyReason;
    }

    try {
      if (-1 == startYear) {
        startYear = Integer.MIN_VALUE;
      }
      if (-1 == endYear) {
        endYear = Integer.MAX_VALUE;
      }
      if (-1 == limEnd) {
        limEnd = Integer.MAX_VALUE;
      }

      // Linked hash set
      List<Publication> pubTemp = publicationService.getPublicationsByConferenceId(jconfid);
      List<Publication> pubSet = Lists.newArrayList();
      int count = 0;
      for (Publication pub : pubTemp) {
        if ((startYear == null || startYear <= pub.getYear())
            && (endYear == null || endYear >= pub.getYear())) {
          if (count >= limStart) {
            pubSet.add(pub);
          }
          count++;
          if (count >= limEnd) {
            break;
          }
        }
      }

      // if has html, return here.
      String htmlResult = support.returnHtml(request, "person_profile.vm", pubSet);
      if (null != htmlResult) {
        return htmlResult;
      }

      Publication[] parray = new Publication[pubSet.size()];
      parray = pubSet.toArray(parray);

      return _returnPublication(request, parray);
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }
コード例 #2
0
  @Published()
  @GET
  @Path("/jconf/{jconfName: .*}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPublicationsByJconfName(
      @DefaultValue("") @PathParam("jconfName") String jconfName,
      @DefaultValue("-1") @QueryParam("startYear") Integer startYear,
      @DefaultValue("-1") @QueryParam("endYear") Integer endYear,
      @DefaultValue("0") @QueryParam("limStart") Integer limStart,
      @DefaultValue("-1") @QueryParam("limEnd") Integer limEnd) {

    // Check permission.
    String denyReason = support.checkPermission(request, uriInfo);
    if (null != denyReason) {
      return denyReason;
    }

    try {
      Jconf jconf = conferenceService.getConference(Strings.replace_back(jconfName));
      if (jconf != null) {
        return getPublicationsByJconfID(jconf.getId(), startYear, endYear, limStart, limEnd);
      } else {
        return "[]";
      }
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }
コード例 #3
0
  @Published()
  @GET
  @Path("/{pubids: [0-9,]+}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPublicationByPubIDs(@DefaultValue("") @PathParam("pubids") String pubIDStr) {

    // Check permission.
    String denyReason = support.checkPermission(request, uriInfo);
    if (null != denyReason) {
      return denyReason;
    }

    String[] ids = pubIDStr.split(",");
    Set<Integer> pubIDSet = new LinkedHashSet<Integer>();
    for (String idstr : ids) pubIDSet.add(Integer.parseInt(idstr.trim()));
    try {
      boolean withAbs = false;
      String fieldSelectString = Strings.safeTrim(REQ.get(request, FIELDS));
      if (fieldSelectString.contains("+abs") || fieldSelectString.contains("abs")) {
        withAbs = true;
      }
      List<Publication> pubSet =
          publicationService.getPublications(withAbs, pubIDSet.toArray(new Integer[] {}));

      // if has html, return here.
      String htmlResult = support.returnHtml(request, "person_profile.vm", pubSet);
      if (null != htmlResult) {
        return htmlResult;
      }

      Publication[] parray = new Publication[pubSet.size()];
      parray = pubSet.toArray(parray);

      return _returnPublication(request, parray);
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }
コード例 #4
0
  /**
   * @param option default tff, [contactInfo, publicationList, coauthors]
   * @return
   */
  @Published()
  @GET
  @Path("/{pubid: [0-9]+}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPublicationByPubID(@DefaultValue("-1") @PathParam("pubid") Integer pubID) {

    // Check permission.
    String denyReason = support.checkPermission(request, uriInfo);
    if (null != denyReason) {
      return denyReason;
    }

    try {
      boolean withAbs = false;
      String fieldSelectString = Strings.safeTrim(REQ.get(request, FIELDS));
      if (fieldSelectString.contains("+abs") || fieldSelectString.contains("abs")) {
        withAbs = true;
      }
      Publication pub = null;
      if (withAbs) {
        pub = publicationService.getPublicationFull(pubID);
      } else {
        pub = publicationService.getPublication(pubID);
      }

      // if has html, return here.
      String htmlResult = support.returnHtml(request, "person_profile.vm", pub);
      if (null != htmlResult) {
        return htmlResult;
      }

      return _returnPublication(request, pub);
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }
コード例 #5
0
  @Published("soa")
  @GET
  @Path("/getPubLocation/{pubid: [0-9]+}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPubLocationById(@DefaultValue("-1") @PathParam("pubid") Integer PubId) {

    // Check permission.
    // String denyReason = support.checkPermission(request, uriInfo);
    // if (null != denyReason) {
    // return denyReason;
    // }

    try {
      Publication pub = publicationService.getPublication(PubId);

      if (null != pub) {
        RealPerson[] authors = pub.getAuthors();
        if (null == authors) {
          return "[]";
        }

        Integer[] ids = new Integer[authors.length];
        for (int i = 0; i < ids.length; ++i) {
          ids[i] = authors[i].getId();
        }
        List<PersonProfile> profiles =
            personService.getProfile((short) (PersonService.ORG_ID | PersonService.CONTACT), ids);
        List<Integer> orgids = Lists.newArrayList();
        for (PersonProfile pp : profiles) {
          orgids.add(pp.getPersonStatisticsData().getOrgid());
        }
        List<Organization> orgs = new ArrayList<Organization>();

        for (int oid : orgids) {
          orgs.add(oid < 0 ? null : orgService.getOrganization(oid));
        }

        String[][] locations = new String[3][];
        locations[0] = new String[orgs.size()];
        locations[1] = new String[orgs.size()];
        locations[2] = new String[orgs.size()];
        Organization tmp = new Organization();
        for (int i = 0; i < orgs.size(); ++i) {
          tmp = orgs.get(i);
          if (tmp == null) {
            locations[0][i] = String.valueOf(-1);
            locations[1][i] = String.valueOf(-1);
            locations[2][i] = "";
          } else {
            locations[0][i] = String.valueOf(tmp.getLongitude());
            locations[1][i] = String.valueOf(tmp.getLatitude());
            locations[2][i] = tmp.getName();
          }
        }

        String json = support.jsonBuilder.toJson(locations);
        return support.wrapReturn(request, json);
      } else {
        return "[]";
      }
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }