Beispiel #1
0
  public String export() {
    response.setContentType("Application/excel");
    response.addHeader("Content-Disposition", "attachment;filename=RoleList.xls");

    int pageNum = getPageNum();
    int numPerPage = getNumPerPage();
    int startIndex = (pageNum - 1) * numPerPage;
    Map<RoleSearchFields, Object> criterias = getCriterias();

    Collection<Role> roleList =
        pMgr.searchRole(criterias, realOrderField(), startIndex, numPerPage);

    XlsExport e = new XlsExport();
    int rowIndex = 0;

    e.createRow(rowIndex++);
    for (ExportFiled filed : ExportFiled.values()) {
      e.setCell(filed.ordinal(), filed.getName());
    }

    for (Role role : roleList) {
      e.createRow(rowIndex++);

      for (ExportFiled filed : ExportFiled.values()) {
        switch (filed) {
          case ROLEID:
            e.setCell(filed.ordinal(), role.getRoleId());
            break;
          case ROLEDESC:
            e.setCell(filed.ordinal(), role.getRoleDesc());
            break;
          case ROLENAME:
            e.setCell(filed.ordinal(), role.getRoleName());
            break;
          default:
            break;
        }
      }
    }

    e.exportXls(response);
    return null;
  }
Beispiel #2
0
 /**
  * Creates a new {@link DiscoveryNode}.
  *
  * <p><b>Note:</b> if the version of the node is unknown {@link
  * Version#minimumCompatibilityVersion()} should be used for the current version. it corresponds
  * to the minimum version this elasticsearch version can communicate with. If a higher version is
  * used the node might not be able to communicate with the remove node. After initial handshakes
  * node versions will be discovered and updated.
  *
  * @param nodeName the nodes name
  * @param nodeId the nodes unique persistent id
  * @param ephemeralId the nodes unique ephemeral id
  * @param hostAddress the nodes host address
  * @param address the nodes transport address
  * @param attributes node attributes
  * @param roles node roles
  * @param version the version of the node
  */
 public DiscoveryNode(
     String nodeName,
     String nodeId,
     String ephemeralId,
     String hostName,
     String hostAddress,
     TransportAddress address,
     Map<String, String> attributes,
     Set<Role> roles,
     Version version) {
   if (nodeName != null) {
     this.nodeName = nodeName.intern();
   } else {
     this.nodeName = "";
   }
   this.nodeId = nodeId.intern();
   this.ephemeralId = ephemeralId.intern();
   this.hostName = hostName.intern();
   this.hostAddress = hostAddress.intern();
   this.address = address;
   if (version == null) {
     this.version = Version.CURRENT;
   } else {
     this.version = version;
   }
   this.attributes = Collections.unmodifiableMap(attributes);
   // verify that no node roles are being provided as attributes
   Predicate<Map<String, String>> predicate =
       (attrs) -> {
         for (Role role : Role.values()) {
           assert attrs.containsKey(role.getRoleName()) == false;
         }
         return true;
       };
   assert predicate.test(attributes);
   Set<Role> rolesSet = EnumSet.noneOf(Role.class);
   rolesSet.addAll(roles);
   this.roles = Collections.unmodifiableSet(rolesSet);
 }