protected String[] buildArguments() {
    Object[] arguments = new String[] {};
    String useSSL = determineClientSSLParameterClass();
    if (useSSL != null) {
      arguments = ArrayUtils.add(arguments, "-ssl");
      arguments = ArrayUtils.add(arguments, useSSL);
    }
    String[] slimFlags = getSlimFlags();
    if (slimFlags != null)
      for (String flag : slimFlags) arguments = ArrayUtils.add(arguments, flag);

    arguments = ArrayUtils.add(arguments, Integer.toString(getSlimPort()));

    return (String[]) arguments;
  }
Ejemplo n.º 2
0
  /**
   * 分页语句 SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY OrderDate) RowNum, * FROM Orders WHERE
   * OrderDate >= '1980-01-01' ) RowConstrainedResult WHERE RowNum >= 1 AND RowNum < 20 ORDER BY
   * RowNum
   */
  @Override
  public StatementWrapper pageStatement(
      String orderCol, String direction, int start, int limit, String strSQL, Object... values) {
    int indexFrom = StringUtils.indexOfIgnoreCase(strSQL, " FROM ");

    if (orderCol.contains(".")) {
      orderCol = orderCol.replaceAll("\\.", "\".\"");
    }
    orderCol = orderCol.toUpperCase();

    StringBuffer sbSQL =
        new StringBuffer("SELECT * FROM (")
            .append(strSQL.substring(0, indexFrom))
            .append(", ROW_NUMBER() OVER (ORDER BY \"")
            .append(orderCol)
            .append("\" ")
            .append(direction)
            .append(") ")
            .append(COLUMN_ROW_NUMBER)
            .append(strSQL.substring(indexFrom))
            .append(") WHERE ")
            .append(COLUMN_ROW_NUMBER)
            .append(" >= ? ");
    if (limit > 0) {
      sbSQL.append(" AND ").append(COLUMN_ROW_NUMBER).append(" <= ? ");
      values = ArrayUtils.addAll(values, new Object[] {start, start + limit});
    } else {
      values = ArrayUtils.add(values, start);
    }
    return new StatementWrapper(sbSQL.toString(), values);
  }
Ejemplo n.º 3
0
 /**
  * 功能:获取除去占比经营数据总收的其它图例
  *
  * <p>作者 杨荣忠 2015-1-19 下午05:04:21
  *
  * @param conditionEntity
  * @return
  */
 public static String[] getZhabiDetach(ConditionEntity conditionEntity) {
   String[] array = getDimensionAll(conditionEntity);
   String[] result = (String[]) ArrayUtils.removeElement(array, ALL_COST);
   result = (String[]) ArrayUtils.removeElement(result, OTHER_ALL_COST);
   String[] result_add = (String[]) ArrayUtils.add(result, OTHER);
   return result_add;
 }
 /**
  * Retrieve a null representation of the cache item. This representation is the same for all cache
  * misses and is used as the object representation to store in the cache for a cache miss.
  *
  * @param responseClass the class representing the type of the cache item
  * @param <T> the type of the cache item
  * @return the null representation for the cache item
  */
 protected synchronized <T> T getNullObject(final Class<T> responseClass) {
   if (nullObject == null) {
     Class<?>[] interfaces =
         (Class<?>[])
             ArrayUtils.add(
                 ClassUtils.getAllInterfacesForClass(responseClass), Serializable.class);
     nullObject =
         Proxy.newProxyInstance(
             getClass().getClassLoader(),
             interfaces,
             new InvocationHandler() {
               @Override
               public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                 if (method.getName().equals("equals")) {
                   return !(objects[0] == null) && objects[0].hashCode() == 31;
                 } else if (method.getName().equals("hashCode")) {
                   return 31;
                 } else if (method.getName().equals("toString")) {
                   return "Null_" + responseClass.getSimpleName();
                 }
                 throw new IllegalAccessException("Not a real object");
               }
             });
   }
   return (T) nullObject;
 }
  public BoundStatementWrapper bindForSimpleCounterIncrementDecrement(
      PersistentStateHolder context,
      PreparedStatement ps,
      PropertyMeta pm,
      Long increment,
      ConsistencyLevel consistencyLevel) {

    EntityMeta entityMeta = context.getEntityMeta();
    Object primaryKey = context.getPrimaryKey();

    log.trace(
        "Bind prepared statement {} for simple counter increment of {} using primary key {} and value {}",
        ps.getQueryString(),
        pm,
        primaryKey,
        increment);
    Object[] boundValues =
        ArrayUtils.add(
            extractValuesForSimpleCounterBinding(entityMeta, pm, primaryKey), 0, increment);

    BoundStatement bs = ps.bind(boundValues);
    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        boundValues,
        getCQLLevel(consistencyLevel),
        NO_LISTENER,
        NO_SERIAL_CONSISTENCY);
  }
Ejemplo n.º 6
0
 /**
  * 向目标数组中动态添加元素. 该方法扩展了ArrayUtils.add,实现了泛形.
  *
  * @param array
  * @param element
  * @return
  */
 @SuppressWarnings("unchecked")
 public static <T> T[] addToArray(T[] array, T element) {
   if (array == null) {
     array = (T[]) Array.newInstance(element.getClass(), 0);
   }
   Object[] newArray = ArrayUtils.add(array, element);
   return (T[]) Arrays.copyOf(newArray, newArray.length, array.getClass());
 }
Ejemplo n.º 7
0
 public GritTransformer(Templates... templates) {
   try {
     Templates gritXslt = TransformerUtil.newTemplates(getClass(), "/xslt/rdfxml-grit.xslt");
     this.templates = (Templates[]) ArrayUtils.add(templates, 0, gritXslt);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 8
0
 /** {@inheritDoc} */
 private Space addInvited(Space space, String userId) {
   String[] invitedUsers = space.getInvitedUsers();
   if (!ArrayUtils.contains(invitedUsers, userId)) {
     invitedUsers = (String[]) ArrayUtils.add(invitedUsers, userId);
     space.setInvitedUsers(invitedUsers);
   }
   return space;
 }
Ejemplo n.º 9
0
 /** {@inheritDoc} */
 private Space addPending(Space space, String userId) {
   String[] pendingUsers = space.getPendingUsers();
   if (!ArrayUtils.contains(pendingUsers, userId)) {
     pendingUsers = (String[]) ArrayUtils.add(pendingUsers, userId);
     space.setPendingUsers(pendingUsers);
   }
   return space;
 }
Ejemplo n.º 10
0
  /**
   * Gets the tokens with special characters.
   *
   * @param tokens the tokens
   * @return the tokens with special characters
   */
  protected String[] getTokensWithSpecialCharacters(String[] tokens) {
    String[] returnArray = new String[0];

    for (String token : tokens) {
      if (doesSearchStringContainSpecialCharacters(token)) {
        returnArray = (String[]) ArrayUtils.add(returnArray, token);
      }
    }
    return returnArray;
  }
Ejemplo n.º 11
0
  /**
   * 获取角色用户的个数
   *
   * @param roleName
   * @param startTime
   * @param endTime
   * @param userId
   * @return
   */
  public int getpage(
      String roleName, String startTime, String endTime, String userId, String provId) {
    // 登录用户对象
    StringBuilder sqlBuff = new StringBuilder(500);

    sqlBuff.setLength(0);
    sqlBuff.append("select count(1) ");
    sqlBuff.append("  from t_sys_role ");
    sqlBuff.append(" where 1=1 ");

    Object[] p = new Object[] {};

    // // 加入登录用户查看角色列表限制,超级管理员可以看到全部
    // if (!Const.SUPER_ADMIN_ID_LIST.contains(userId)) {
    // sqlBuff.append(" and update_user_id = ? ");
    // p = ArrayUtils.add(p, userId);
    // }

    if (StringUtils.isNotBlank(roleName)) {
      sqlBuff.append(" and ( name like ? or remark like ? )");
      p = ArrayUtils.add(p, "%" + roleName + "%");
      p = ArrayUtils.add(p, "%" + roleName + "%");
    }

    if (StringUtils.isNotBlank(startTime)) {
      sqlBuff.append(" and update_time >= ?");
      p = ArrayUtils.add(p, startTime + "000000");
    }

    if (StringUtils.isNotBlank(endTime)) {
      sqlBuff.append(" and update_time <= ?");
      p = ArrayUtils.add(p, endTime + "235959");
    }
    if (StringUtils.isNotBlank(provId)) {
      sqlBuff.append(" and rel_prov = ?");
      p = ArrayUtils.add(p, provId);
    }

    int num = jdbcTemplate.queryForInt(sqlBuff.toString(), p);
    return num;
  }
Ejemplo n.º 12
0
 public static String[] combine(Object... strings) {
   String[] combined = {};
   for (int i = 0; i < strings.length; i++) {
     Object obj = strings[i];
     if (obj instanceof String[]) {
       combined = (String[]) ArrayUtils.addAll(combined, (Object[]) strings[i]);
     } else {
       combined = (String[]) ArrayUtils.add(combined, obj.toString());
     }
   }
   return combined;
 }
Ejemplo n.º 13
0
 /** {@inheritDoc} */
 public void addMember(Space space, String userId) {
   String[] members = space.getMembers();
   space = this.removeInvited(space, userId);
   space = this.removePending(space, userId);
   if (!ArrayUtils.contains(members, userId)) {
     members = (String[]) ArrayUtils.add(members, userId);
     space.setMembers(members);
     this.updateSpace(space);
     SpaceUtils.addUserToGroupWithMemberMembership(userId, space.getGroupId());
     spaceLifeCycle.memberJoined(space, userId);
   }
 }
Ejemplo n.º 14
0
  @Override
  public byte[] encode(EncContext ctx) {
    String value = (String) ctx.getEncObject();

    byte[] bytes = null;

    if (null == value) {
      return new byte[] {0};
    }

    try {
      bytes = value.getBytes(XIP_STR_CHARSET);
    } catch (UnsupportedEncodingException e) {
      logger.error("CStyleString", e);
    }

    return ArrayUtils.add(bytes, (byte) 0);
  }
Ejemplo n.º 15
0
  public void add() {
    String toUser = $V("ToUser");
    if (!StringUtil.checkID(toUser)) {
      this.Response.setLogInfo(0, "传入参数错误!");
      return;
    }
    String[] userList = toUser.split(",");

    String toRole = $V("ToRole");
    if (!StringUtil.checkID(toRole)) {
      this.Response.setLogInfo(0, "传入参数错误!");
      return;
    }
    String[] roleList = toRole.split(",");

    if (roleList.length > 0) {
      String roleStr = "";
      for (int j = 0; j < roleList.length; ++j) {
        if (StringUtil.isNotEmpty(roleList[j])) {
          if (j == 0) roleStr = roleStr + "'" + roleList[j] + "'";
          else {
            roleStr = roleStr + ",'" + roleList[j] + "'";
          }
        }
      }
      if (StringUtil.isNotEmpty(roleStr)) {
        DataTable dt =
            new QueryBuilder("select UserName from zduserRole where rolecode in (" + roleStr + ")")
                .executeDataTable();
        for (int k = 0; k < dt.getRowCount(); ++k) {
          String userName = dt.getString(k, "UserName");
          if ((!User.getUserName().equals(userName))
              && (!ArrayUtils.contains(userList, userName))) {
            userList = (String[]) ArrayUtils.add(userList, userName);
          }
        }
      }
    }

    if (MessageCache.addMessage($V("Subject"), $V("Content"), userList, User.getUserName()))
      this.Response.setLogInfo(1, "新建成功!");
    else this.Response.setLogInfo(0, "新建失败!");
  }
Ejemplo n.º 16
0
 /** {@inheritDoc} */
 public void setManager(Space space, String userId, boolean isManager) {
   String[] managers = space.getManagers();
   if (isManager) {
     if (!ArrayUtils.contains(managers, userId)) {
       managers = (String[]) ArrayUtils.add(managers, userId);
       space.setManagers(managers);
       this.updateSpace(space);
       SpaceUtils.addUserToGroupWithManagerMembership(userId, space.getGroupId());
       spaceLifeCycle.grantedLead(space, userId);
     }
   } else {
     if (ArrayUtils.contains(managers, userId)) {
       managers = (String[]) ArrayUtils.removeElement(managers, userId);
       space.setManagers(managers);
       this.updateSpace(space);
       SpaceUtils.removeUserFromGroupWithManagerMembership(userId, space.getGroupId());
       spaceLifeCycle.revokedLead(space, userId);
     }
   }
 }
Ejemplo n.º 17
0
 @Override
 public LdapUserContext findUser(String identityAttributeValue) throws LdapException {
   try {
     Filter userClassFilter;
     if (userObjectClass != null && !userObjectClass.isEmpty()) {
       userClassFilter = Filter.createEqualityFilter("objectClass", userObjectClass);
     } else {
       userClassFilter = Filter.createPresenceFilter("objectClass");
     }
     Filter filter =
         Filter.createANDFilter(
             userClassFilter,
             Filter.createEqualityFilter(userIdentityAttribute, identityAttributeValue));
     LOGGER.debug(filter.toString());
     String[] attributesToRetrieve;
     if (userAdditionalAttributes != null) {
       attributesToRetrieve = userAdditionalAttributes;
       if (!ArrayUtils.contains(attributesToRetrieve, "cn")
           || !ArrayUtils.contains(attributesToRetrieve, "CN")) {
         ArrayUtils.add(attributesToRetrieve, "cn");
       }
     } else {
       attributesToRetrieve = new String[] {"cn"};
     }
     SearchResult searchResult =
         ldapConnectionPool.search(
             StringUtils.join(userBase, ','), SearchScope.SUB, filter, attributesToRetrieve);
     if (searchResult.getEntryCount() != 1) {
       throw new UnknownAccountException();
     }
     SearchResultEntry searchResultEntry = searchResult.getSearchEntries().get(0);
     String dn = searchResultEntry.getDN();
     DefaultLdapUserContext ldapUserContext = internalCreateUser(dn);
     ldapUserContext.getKnownAttributes().put("cn", searchResultEntry.getAttributeValue("cn"));
     return ldapUserContext;
   } catch (com.unboundid.ldap.sdk.LDAPException e) {
     throw new LdapException(e);
   }
 }
Ejemplo n.º 18
0
  @TraceCall
  @Override
  public void destroyPage(Context ctx, long pageId, boolean destroyAssociated) {
    checkUpdatePagePermission(ctx, pageId);
    String sql;

    SQLExecutor se = getSqlExecutor();
    if (destroyAssociated) {
      sql =
          new SQLBuilder.Select()
              .select("associated_id", "free_circle_ids")
              .from(pageTable)
              .where("destroyed_time=0 AND page_id = ${v(page_id)}", "page_id", pageId)
              .toString();
      Record pageRec = se.executeRecord(sql, null);
      if (MapUtils.isNotEmpty(pageRec)) {
        long associatedId = pageRec.getInt("associated_id");
        long[] freeCircleIds =
            StringUtils2.splitIntArray(pageRec.getString("free_circle_ids"), ",");
        long[] allCircleIds =
            associatedId > 0 ? ArrayUtils.add(freeCircleIds, 0, associatedId) : freeCircleIds;
        for (long circleId : allCircleIds) {
          GlobalLogics.getGroup()
              .updateGroupSimple(ctx, circleId, new Record(), Record.of("page_id", 0L));
        }
      }
    }

    sql =
        new SQLBuilder.Update()
            .update(pageTable)
            .value("destroyed_time", DateUtils.nowMillis())
            .where("page_id=${v(page_id)}", "page_id", pageId)
            .toString();

    se.executeUpdate(sql);
  }
  public static void main(String[] args)
      throws InvalidProperty, RuntimeFault, RemoteException, MalformedURLException {
    ServiceInstance si =
        new ServiceInstance(
            new URL(args[0]),
            args[1],
            args[2],
            true); // Pass 3 argument as vCenterIP/username/password
    String ClusterName = "Cluster"; // Cluster Name
    String VMToBeRemoved = "VM1";
    String VMToBeAdded = "VM3";
    Folder rootFolder = si.getRootFolder();
    VirtualMachine vm1 =
        (VirtualMachine)
            new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", VMToBeRemoved);
    VirtualMachine vm2 =
        (VirtualMachine)
            new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", VMToBeAdded);
    ManagedObjectReference vmMor1 = vm1.getMOR();
    ManagedObjectReference vmMor2 = vm2.getMOR();

    ClusterComputeResource cluster = null;
    cluster =
        (ClusterComputeResource)
            new InventoryNavigator(rootFolder)
                .searchManagedEntity("ClusterComputeResource", ClusterName);

    // Number of rules in a cluster
    ClusterRuleInfo[] ruleinfo = ((ClusterConfigInfoEx) cluster.getConfigurationEx()).getRule();

    if (ruleinfo == null || ruleinfo.length == 0) {
      System.out.println("There is no DRS rule in the cluster:: " + cluster.getName());
    }

    for (ClusterRuleInfo rule : ruleinfo) {
      if (((rule instanceof ClusterAffinityRuleSpec)) && (rule.getName().equals("VM VM Rule"))) {
        ManagedObjectReference[] vms = ((ClusterAffinityRuleSpec) rule).getVm();
        for (ManagedObjectReference vm : vms) {
          if (vm.getVal().equals(vmMor1.getVal())) {
            // Removed the VM from rule
            vms = (ManagedObjectReference[]) ArrayUtils.removeElement(vms, vm);
            break;
          }
        }
        // Added the new VM to the rule
        vms = (ManagedObjectReference[]) ArrayUtils.add(vms, vmMor2);

        ClusterAffinityRuleSpec cars = (ClusterAffinityRuleSpec) rule;
        cars.setVm(vms);

        ClusterRuleSpec crs1 = new ClusterRuleSpec();
        crs1.setInfo(cars);
        crs1.setOperation(ArrayUpdateOperation.edit);

        ClusterConfigSpec ccs = new ClusterConfigSpec();
        ccs.setRulesSpec(new ClusterRuleSpec[] {crs1});

        cluster.reconfigureCluster_Task(ccs, true);
        System.out.println("Rule reconfigured successfully ");
        si.getServerConnection().logout();
      }
    }
  }
Ejemplo n.º 20
0
  /**
   * 通过查询对象、条件和显示字段构造查询语句,返回符合条件的查询结果。
   *
   * <p>创建日期:(2001-5-15)
   *
   * @return StatValueObject[] 查到的VO对象数组
   * @param QueryStructVO voQryStruct 查询结构
   * @exception BusinessException 异常说明。
   */
  public RSTransferVO getQueryResult(QueryStructVO voQryStruct) throws BusinessException {
    try {

      RSTransferVO voResult = new RSTransferVO();
      MemoryResultSet[] mrsResults = null;

      // add by wdg(2007-10-18)
      // 期初暂估冲回数据
      MemoryResultSet[] tempEstimateInitMrsResults = null;
      // 暂估发生数据
      MemoryResultSet[] tempEstimateOccurMrsResults = null;
      for (int i = 0; i < voQryStruct.getVetQryObj().size(); i++) {
        if (nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
            .getStrByID("2006", "UPTcommon-0100172") /*@res "客商"*/
            .equals(voQryStruct.getVetQryObj().get(i).getM_strDisplayName())) {
          voQryStruct.getVetQryObj().get(i).setPk_bdinfo("00010000000000000073");
        }
      }
      if (voQryStruct.getSecsrc() != null) {
        InvocationInfoProxy.getInstance().setUserDataSource(voQryStruct.getSecsrc());
      }
      if (true) {
        ListQueryMetadata queryMetadata =
            new ListQueryMetadata(QueryMetadataUtil.convertQryStruct2Metadata(voQryStruct));
        DateRange dateRange = new DateRange();
        dateRange.setStartDate(voQryStruct.getSumDate()[0]);
        dateRange.setEndDate(voQryStruct.getSumDate()[1]);
        queryMetadata.getConfig().setSumDateRange(dateRange);
        queryMetadata.getConfig().setMonthQuery(voQryStruct.isQuerybyPeriod());
        if (voQryStruct.getSecsrc() == null) {
          BalQryObjLogUtil.log(
              queryMetadata.getQueryObjects(),
              queryMetadata.getConfig().getSystem() == SysEnum.YS ? "20060504" : "20080504");
        }

        voResult = new ListQueryBO().query(queryMetadata);
        mrsResults = voResult.getResultset();
      } else {

        /** 插入单据信息,这是明细查询中的必查项目 */
        Vector<QryObjVO> vetDisplay = voQryStruct.getVetDisplay();
        vetDisplay = insertDjxx(vetDisplay);
        voQryStruct.setVetDisplay(vetDisplay);
        Vector vetObj = voQryStruct.getVetQryObj();
        vetObj = PubMethodVO.mergeVector(vetObj, voQryStruct.getVetGroupBy());
        voQryStruct.setVetQryObj(vetObj);
        voQryStruct.setVetGroupBy(new Vector());
        ICreateSql createTools = getSqlCreater();
        if (voQryStruct.isWanglaiDetail()) {
          createTools = new CreateSql_WL();
        }
        /*设置需要的查询语句*/
        int[] iPos;
        boolean[] bSum;
        if (!voQryStruct.isQuerybyPeriod()) {
          /*日期模式*/
          iPos =
              new int[] {
                0, 1, 2, 3, /*4, 5, 6, 7, 8, 9, 10*/
              };
          bSum =
              new boolean[] {
                false, false, false, false, /* false, false, false, false, false, false, false */
              };
        } else {
          /*期间模式*/
          iPos =
              new int[] {
                0, 1, 2, 3, /* 4, 5, 6, 7, 8, 9, 10, */ 2, 3, /*4, 5, 6, 7, 8, 9, 10*/
              };
          bSum =
              new boolean[] {
                false,
                false,
                false,
                false,
                /*
                false,
                false,
                false,
                false,
                false,
                false,
                false,*/
                true,
                true,
                /*true,
                true,
                true,
                true,
                true,
                true,
                true */ };
        }
        /*-----设置完毕----*/

        NewListQueryDAO dmo = new NewListQueryDAO();
        //        Debug.println("调用dmo类,进行查询");

        // zhongyue_begin for  多单位权限控制 begin
        nc.bs.arap.pub.CreatJoinSQLTool jointool = new nc.bs.arap.pub.CreatJoinSQLTool();
        if (voQryStruct.getSecsrc() != null) {
          InvocationInfoProxy.getInstance().setUserDataSource(voQryStruct.getSecsrc());
        }
        if (jointool.checkLegal(voQryStruct.getCorp())) {
          createTools.setQueryIdx(iPos, bSum);
          createTools.setDateType(voQryStruct);
          createTools.initParam(voQryStruct);
          String[] strSqls = createTools.getSQL();
          mrsResults = dmo.getQueryResult(strSqls);
        } else {
          String[] sPk_corps = voQryStruct.getCorp();
          if (sPk_corps != null) {
            for (int i = 0; i < sPk_corps.length; i++) {
              String[] tables = new PowerCtrlVO(sPk_corps[i]).getTables();
              if (voQryStruct.getPowerCtrlVO() != null) {
                voQryStruct.getPowerCtrlVO().setTables(tables);
              }
              voQryStruct.setCorp(new String[] {sPk_corps[i]});
              if (voQryStruct.getPowerCtrlVO() != null) {
                voQryStruct.getPowerCtrlVO().setPk_corp(new String[] {sPk_corps[i]});
              }
              createTools = getSqlCreater();
              if (voQryStruct.isWanglaiDetail()) {
                createTools = new CreateSql_WL();
              }
              createTools.setQueryIdx(iPos, bSum);
              createTools.setDateType(voQryStruct);
              createTools.initParam(voQryStruct);

              String[] strSqls = createTools.getSQL();
              mrsResults = mergeMultiCorps(mrsResults, dmo.getQueryResult(strSqls));
            }
          }
        }
      }
      String[] sPk_corps = voQryStruct.getCorp();
      if (sPk_corps != null) {
        for (int i = 0; i < sPk_corps.length; i++) {
          // 期初冲回数据要考虑数据权限,否则查出的无权限数据加入原期初结果集会造成数据增多
          if (!voQryStruct.isBlnClearEstimateDataShow()) {
            tempEstimateInitMrsResults =
                mergeMultiCorps(
                    tempEstimateInitMrsResults, getInitTempEstimateOffsetData(voQryStruct));
            tempEstimateOccurMrsResults =
                mergeMultiCorps(tempEstimateOccurMrsResults, getTempEstimateData(voQryStruct));
          }
        }
      }

      // end
      if (voQryStruct.isVouchshow()) {
        PubMethodVO.insertVouchidCol(mrsResults);
      }
      VOCompress.objectReference(mrsResults);
      voResult.setResultset(mrsResults);

      /*删除控制数据权限建立的临时表*/
      // new PubDMO().onDropTemTab(createTools.getPowerHashtable());

      // 如果查询条件为“已两清的暂估单据不显示”(add by wdg:2007-10-11)
      if (!voQryStruct.isBlnClearEstimateDataShow()) {
        mergeTempEstimateData(
            voQryStruct, voResult, tempEstimateInitMrsResults, tempEstimateOccurMrsResults);
      }

      if (!voQryStruct.isRecheck()
          && !(voQryStruct
                  .getStrBillType()
                  .equals(
                      NCLangRes4VoTransl.getNCLangRes()
                          .getStrByID("20060504", "UPP20060504-000228"))
              || voQryStruct
                  .getStrBillType()
                  .equals(
                      NCLangRes4VoTransl.getNCLangRes()
                          .getStrByID("20060504", "UPP20060504-000230")))) {
        Iterator<QryObjVO> iterator = voQryStruct.getVetQryObj().iterator();
        while (iterator.hasNext()) {
          QryObjVO qryObjVO = iterator.next();
          if ("bzbm".equals(qryObjVO.getQryfld())) {
            iterator.remove();
          }
        }
      }

      voResult.setObjs(getJoinTools().getQryObjs(voQryStruct.getVetQryObj()));
      voResult.setDisplays(getJoinTools().getQryObjs(voQryStruct.getVetDisplay()));
      MemoryResultSet sumRs = null;
      MemoryResultSet[] mrs = voResult.getResultset();
      if (isLastPageIndex(voQryStruct, voResult)) {
        sumRs = voResult.getResultset()[voResult.getResultset().length - 1];
        mrs =
            (MemoryResultSet[])
                ArrayUtils.subarray(voResult.getResultset(), 0, voResult.getResultset().length - 1);
      }
      MemoryResultSet[] mrsSource =
          prepareData(
              mrs,
              voQryStruct,
              voQryStruct.isQuerybyPeriod(),
              voResult.getObjs(),
              voResult.getDisplays());
      if (mrsSource != null) {
        int total = 0;
        for (MemoryResultSet ms : mrsSource) {
          if (ms != null && ms.getResultArrayList() != null)
            total += ms.getResultArrayList().size();
        }
        if (total > 20000) {
          throw new BusinessException("记录超过两万条,请分页查或缩小查询范围");
        }
      }
      voResult.setResultset(mrsSource);
      if (sumRs != null) {
        voResult.setResultset((MemoryResultSet[]) ArrayUtils.add(mrsSource, sumRs));
      }
      PubMethodVO.createCodeAndName(voResult.getObjs());
      PubMethodVO.insertCodeAndNameColumns(voResult.getResultset(), voResult.getObjs());
      return voResult;
    } catch (Exception e) {
      Log.getInstance(this.getClass()).error(e.getMessage());
      throw new BusinessShowException(e.getMessage());
    }
  }
Ejemplo n.º 21
0
   public DocumentList crawl() {
     prepareList();
     try {
       this.list.setCrawler(this);
       this.fileDownloader
         .setDenyExtension(".gif.jpg.jpeg.swf.bmp.png.js.wmv.css.ico.avi.mpg.mpeg.mp3.mp4.wma.rm.rmvb.exe.tar.gz.zip.rar");
       this.fileDownloader.setThreadCount(this.config.getThreadCount());
       this.fileDownloader.setTimeout(this.config.getTimeout() * 1000);
 
       if (this.config.isProxyFlag()) {
         this.fileDownloader.setProxyFlag(this.config.isProxyFlag());
         this.fileDownloader.setProxyHost(this.config.getProxyHost());
         this.fileDownloader.setProxyPassword(this.config.getProxyPassword());
         this.fileDownloader.setProxyUserName(this.config.getProxyUserName());
         this.fileDownloader.setProxyPort(this.config.getProxyPort());
       } else if ("Y".equalsIgnoreCase(Config.getValue("Proxy.IsUseProxy"))) {
         this.fileDownloader.setProxyFlag(true);
         this.fileDownloader.setProxyHost(Config.getValue("Proxy.Host"));
         this.fileDownloader.setProxyPassword(Config.getValue("Proxy.Password"));
         this.fileDownloader.setProxyUserName(Config.getValue("Proxy.UserName"));
         this.fileDownloader.setProxyPort(Integer.parseInt(Config.getValue("Proxy.Port")));
       }
 
       prepareScript();
       for (int i = 0; (i < this.config.getUrlLevels().length) && (i <= this.config.getMaxLevel()); ++i) {
         try {
           if ((i >= this.startLevel) || (this.task.checkStop()))
           {
             this.task.setCurrentInfo("正在处理第" + (i + 1) + "层级URL");
             this.currentLevel = i;
             dealOneLevel();
           }
         } catch (Throwable e) {
           e.printStackTrace();
         }
       }
       if (this.task.checkStop())
         break label457;
       if (this.config.isCopyImageFlag()) {
         int maxPage = this.config.getMaxPageCount();
         this.config.setMaxPageCount(-1);
         this.fileDownloader
           .setDenyExtension(".html.htm.jsp.php.asp.shtml.swf.js.css.ico.avi.mpg.mpeg.mp3.mp4.wma.wmv.rm.rmvb.exe.tar.gz.zip.rar");
         this.currentLevel += 1;
         this.task.setCurrentInfo("正在处理第" + (this.currentLevel + 1) + "层级URL");
         String[] urls = this.config.getUrlLevels();
         urls = (String[])
           ArrayUtils.add(urls, 
           "${A}.gif\n${A}.jpg\n${A}.jpeg\n${A}.png\n${A}.bmp\n${A}.GIF\n${A}.JPG\n${A}.JPEG\n${A}.PNG\n${A}.BMP");
         this.config.setUrlLevels(urls);
         dealOneLevel();
         this.config.setMaxPageCount(maxPage);
         this.fileDownloader
           .setDenyExtension(".gif.jpg.jpeg.swf.bmp.png.js.wmv.css.ico.avi.mpg.mpeg.mp3.mp4.wma.rm.rmvb.exe.tar.gz.zip.rar");
       }
       retryWithFilter();
       label457: writeArticle();
     }
     catch (Exception e1) {
       e1.printStackTrace();
       return null;
     } finally {
       this.list.save();
       this.list.close();
     }
     return this.list;
   }
  protected void apply(
      FaceletContext ctx,
      UIComponent parent,
      Widget widget,
      String componentType,
      String rendererType)
      throws WidgetException, IOException {
    FaceletHandlerHelper helper = new FaceletHandlerHelper(tagConfig);
    String mode = widget.getMode();
    String widgetId = widget.getId();
    String widgetName = widget.getName();
    String widgetTagConfigId = widget.getTagConfigId();
    List<String> excludedProps = getExcludedProperties();
    TagAttributes attributes = helper.getTagAttributes(widget, excludedProps, true);
    // BBB for CSS style classes on directory select components
    if (widget.getProperty("cssStyle") != null) {
      attributes =
          FaceletHandlerHelper.addTagAttribute(
              attributes, helper.createAttribute("style", (String) widget.getProperty("cssStyle")));
    }
    if (widget.getProperty("cssStyleClass") != null) {
      attributes =
          FaceletHandlerHelper.addTagAttribute(
              attributes,
              helper.createAttribute("styleClass", (String) widget.getProperty("cssStyleClass")));
    }
    if (!BuiltinWidgetModes.isLikePlainMode(mode)) {
      attributes =
          FaceletHandlerHelper.addTagAttribute(attributes, helper.createAttribute("id", widgetId));
    }
    if (BuiltinWidgetModes.EDIT.equals(mode)) {
      FaceletHandler optionsHandler = getOptionsFaceletHandler(ctx, helper, widget);
      FaceletHandler[] nextHandlers = new FaceletHandler[] {};
      nextHandlers = (FaceletHandler[]) ArrayUtils.add(nextHandlers, optionsHandler);
      FaceletHandler leaf =
          getNextHandler(ctx, tagConfig, widget, nextHandlers, helper, true, true);
      // maybe add convert handler for easier integration of select2
      // widgets handling multiple values
      if (HtmlSelectManyListbox.COMPONENT_TYPE.equals(componentType)
          || HtmlSelectManyCheckbox.COMPONENT_TYPE.equals(componentType)
          || HtmlSelectManyMenu.COMPONENT_TYPE.equals(componentType)) {
        // add hint for value conversion to collection
        attributes =
            FaceletHandlerHelper.addTagAttribute(
                attributes, helper.createAttribute("collectionType", ArrayList.class.getName()));
      }

      ComponentHandler input =
          helper.getHtmlComponentHandler(
              widgetTagConfigId, attributes, leaf, componentType, rendererType);
      String msgId = FaceletHandlerHelper.generateMessageId(ctx, widgetName);
      ComponentHandler message =
          helper.getMessageComponentHandler(widgetTagConfigId, msgId, widgetId, null);
      FaceletHandler[] handlers = {getComponentFaceletHandler(ctx, helper, widget, input), message};
      FaceletHandler h = new CompositeFaceletHandler(handlers);
      h.apply(ctx, parent);
    } else {
      // TODO
      return;
    }
  }
Ejemplo n.º 23
0
 public BuildingTable addFilter(BuildingCategory t) {
   this.filter = (BuildingCategory[]) ArrayUtils.add(filter, t);
   return this;
 }
Ejemplo n.º 24
0
  /**
   * @brief 数组工具
   * @details 详细说明
   * @warning 注意事项
   * @date 2014-7-11 上午11:25:18
   */
  @Test
  public void array() {
    // 追加元素到数组尾部
    int[] array1 = {1, 2};
    array1 = ArrayUtils.add(array1, 3); // => [1, 2, 3]

    System.out.println(array1.length); // 3
    System.out.println(array1[2]); // 3

    // 删除指定位置的元素
    int[] array2 = {1, 2, 3};
    array2 = ArrayUtils.remove(array2, 2); // => [1, 2]

    System.out.println(array2.length); // 2

    // 截取部分元素
    int[] array3 = {1, 2, 3, 4};
    array3 = ArrayUtils.subarray(array3, 1, 3); // => [2, 3]

    System.out.println(array3.length); // 2

    // 数组拷贝
    String[] array4 = {"aaa", "bbb", "ccc"};
    String[] copied = (String[]) ArrayUtils.clone(array4); // => {"aaa", "bbb", "ccc"}

    System.out.println(copied.length); // 3

    // 判断是否包含某元素
    String[] array5 = {"aaa", "bbb", "ccc", "bbb"};
    boolean result1 = ArrayUtils.contains(array5, "bbb"); // => true
    System.out.println(result1); // true

    // 判断某元素在数组中出现的位置(从前往后,没有返回-1)
    int result2 = ArrayUtils.indexOf(array5, "bbb"); // => 1
    System.out.println(result2); // 1

    // 判断某元素在数组中出现的位置(从后往前,没有返回-1)
    int result3 = ArrayUtils.lastIndexOf(array5, "bbb"); // => 3
    System.out.println(result3); // 3

    // 数组转Map
    Map<Object, Object> map =
        ArrayUtils.toMap(
            new String[][] {
              {"key1", "value1"},
              {"key2", "value2"}
            });
    System.out.println(map.get("key1")); // "value1"
    System.out.println(map.get("key2")); // "value2"

    // 判断数组是否为空
    Object[] array61 = new Object[0];
    Object[] array62 = null;
    Object[] array63 = new Object[] {"aaa"};

    System.out.println(ArrayUtils.isEmpty(array61)); // true
    System.out.println(ArrayUtils.isEmpty(array62)); // true

    // 判断数组长度是否相等
    Object[] array71 = new Object[] {"aa", "bb", "cc"};
    Object[] array72 = new Object[] {"dd", "ee", "ff"};

    System.out.println(ArrayUtils.isSameLength(array71, array72)); // true

    // 判断数组元素内容是否相等
    Object[] array81 = new Object[] {"aa", "bb", "cc"};
    Object[] array82 = new Object[] {"aa", "bb", "cc"};

    System.out.println(ArrayUtils.isEquals(array81, array82));

    // Integer[] 转化为 int[]
    Integer[] array9 = new Integer[] {1, 2};
    int[] result = ArrayUtils.toPrimitive(array9);

    System.out.println(result.length); // 2
    System.out.println(result[0]); // 1

    // int[] 转化为 Integer[]
    int[] array10 = new int[] {1, 2};
    Integer[] result10 = ArrayUtils.toObject(array10);

    System.out.println(result.length); // 2
    System.out.println(result10[0].intValue()); // 1
  }
 public void addParameter(String name, String value) {
   String[] oldValues = parameterMap.get(name);
   String[] newValues = (String[]) ArrayUtils.add(oldValues, value);
   parameterMap.put(name, newValues);
 }
Ejemplo n.º 26
0
  /** {@inheritDoc} */
  @SuppressWarnings("deprecation")
  public Space createSpace(Space space, String creator, String invitedGroupId) {
    // Creates new space by creating new group
    String groupId = null;
    try {
      groupId = SpaceUtils.createGroup(space.getPrettyName(), creator);
    } catch (SpaceException e) {
      LOG.error("Error while creating group", e);
    }

    if (invitedGroupId != null) { // Invites user in group join to new created
      // space.
      // Gets users in group and then invites user to join into space.
      OrganizationService org = getOrgService();
      try {

        // Cannot use due to http://jira.exoplatform.org/browse/EXOGTN-173
        // ListAccess<User> groupMembersAccess =
        // org.getUserHandler().findUsersByGroup(invitedGroupId);
        // User [] users = groupMembersAccess.load(0, groupMembersAccess.getSize());
        PageList<User> groupMembersAccess = org.getUserHandler().findUsersByGroup(invitedGroupId);
        List<User> users = groupMembersAccess.getAll();

        for (User user : users) {
          String userId = user.getUserName();
          if (!userId.equals(creator)) {
            String[] invitedUsers = space.getInvitedUsers();
            if (!ArrayUtils.contains(invitedUsers, userId)) {
              invitedUsers = (String[]) ArrayUtils.add(invitedUsers, userId);
              space.setInvitedUsers(invitedUsers);
            }
          }
        }
      } catch (Exception e) {
        LOG.error("Failed to invite users from group " + invitedGroupId, e);
      }
    }

    String prettyName = groupId.split("/")[2];

    if (!prettyName.equals(space.getPrettyName())) {
      // work around for SOC-2366
      space.setPrettyName(groupId.split("/")[2]);
    }

    String[] managers = new String[] {creator};
    String[] members = new String[] {creator};
    space.setManagers(managers);
    space.setMembers(members);
    space.setGroupId(groupId);
    space.setUrl(space.getPrettyName());

    saveSpace(space, true);
    spaceLifeCycle.spaceCreated(space, creator);

    try {
      SpaceApplicationHandler spaceApplicationHandler = getSpaceApplicationHandler(space);
      spaceApplicationHandler.initApps(space, getSpaceApplicationConfigPlugin());
      for (SpaceApplication spaceApplication :
          getSpaceApplicationConfigPlugin().getSpaceApplicationList()) {
        setApp(
            space,
            spaceApplication.getPortletName(),
            spaceApplication.getAppTitle(),
            spaceApplication.isRemovable(),
            Space.ACTIVE_STATUS);
      }
    } catch (Exception e) {
      LOG.warn("Failed to init apps", e);
    }

    saveSpace(space, false);

    return space;
  }
Ejemplo n.º 27
0
  /**
   * 获取角色列表信息
   *
   * @param roleName
   * @param startTime
   * @param endTime
   * @param userId
   * @return
   */
  public List<Map<String, Object>> getRoleList(
      String roleName,
      String startTime,
      String endTime,
      String userId,
      String provId,
      int startNo,
      int endNo) {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    // 登录用户对象
    StringBuilder sqlBuff = new StringBuilder(500);

    sqlBuff.setLength(0);

    sqlBuff.append("select role.id, ");
    sqlBuff.append("       role.name, ");
    sqlBuff.append("       role.remark, ");
    sqlBuff.append("       role.update_user_id, ");
    sqlBuff.append("       role.update_time, ");
    sqlBuff.append("       prov.prov_name ");
    sqlBuff.append("  from t_sys_role role, t_sys_province prov ");
    sqlBuff.append(" where 1 = 1 ");
    sqlBuff.append("   and prov.id = role.rel_prov");

    Object[] p = new Object[] {};
    //
    // // 加入登录用户查看角色列表限制,超级管理员可以看到全部
    // if (!Const.SUPER_ADMIN_ID_LIST.contains(userId)) {
    // sqlBuff.append(" and role.update_user_id = ? ");
    // p = ArrayUtils.add(p, userId);
    // }

    if (StringUtils.isNotBlank(roleName)) {
      sqlBuff.append(" and ( role.name like ? or role.remark like ? )");
      p = ArrayUtils.add(p, "%" + roleName + "%");
      p = ArrayUtils.add(p, "%" + roleName + "%");
    }

    if (StringUtils.isNotBlank(startTime)) {
      sqlBuff.append(" and role.update_time >= ?");
      p = ArrayUtils.add(p, startTime + "000000");
    }

    if (StringUtils.isNotBlank(endTime)) {
      sqlBuff.append(" and role.update_time <= ?");
      p = ArrayUtils.add(p, endTime + "235959");
    }
    if (StringUtils.isNotBlank(provId)) {
      sqlBuff.append(" and role.rel_prov like ? ");
      p = ArrayUtils.add(p, provId);
    }
    sqlBuff.append(" order by id desc ");

    // 加上分页参数
    p = ArrayUtils.add(p, endNo);
    p = ArrayUtils.add(p, startNo);

    try {
      list = jdbcTemplate.queryForList(SQLPagingUtils.getPagingSQL(sqlBuff.toString()), p);
    } catch (DataAccessException e) {
      logger.info("查询角色列表出现异常。", e);
      throw new SPlatformDaoException("查询角色列表出现异常。", e);
    }

    if (list == null) {
      list = new ArrayList<Map<String, Object>>();
    }
    return list;
  }
Ejemplo n.º 28
0
 @Override
 protected String[] getConfigLocations() {
   return (String[]) ArrayUtils.add(super.getConfigLocations(), WEB_CLIENT_APPLICATION_CONTEXT);
 }
Ejemplo n.º 29
0
 protected Object[] getExpectedTableRow(String[] paramValues) {
   Object[] expected = super.getExpectedTableRow(paramValues);
   expected = ArrayUtils.add(expected, 2, "Disabled");
   return ArrayUtils.add(expected, "");
 }
 public void addFileItem(String name, FileItem item) {
   FileItem[] oldValues = fileItemMap.get(name);
   FileItem[] newValues = (FileItem[]) ArrayUtils.add(oldValues, item);
   fileItemMap.put(name, newValues);
 }