Esempio n. 1
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;
 }
Esempio n. 2
0
 /** {@inheritDoc} */
 private Space removeInvited(Space space, String userId) {
   String[] invitedUsers = space.getInvitedUsers();
   if (ArrayUtils.contains(invitedUsers, userId)) {
     invitedUsers = (String[]) ArrayUtils.removeElement(invitedUsers, userId);
     space.setInvitedUsers(invitedUsers);
   }
   return space;
 }
Esempio n. 3
0
 /** {@inheritDoc} */
 private Space removePending(Space space, String userId) {
   String[] pendingUsers = space.getPendingUsers();
   if (ArrayUtils.contains(pendingUsers, userId)) {
     pendingUsers = (String[]) ArrayUtils.removeElement(pendingUsers, userId);
     space.setPendingUsers(pendingUsers);
   }
   return space;
 }
Esempio n. 4
0
 @Override
 public void action(DomainMessage domainMessage) {
   long[] id = (long[]) domainMessage.getEventSource();
   id = ArrayUtils.removeElement(id, 0);
   if (ArrayUtils.isNotEmpty(id)) {
     domainMessage.setEventResult(answerRepository.forbidAnswer(id));
   }
 }
Esempio n. 5
0
 /** {@inheritDoc} */
 public void removeMember(Space space, String userId) {
   String[] members = space.getMembers();
   if (ArrayUtils.contains(members, userId)) {
     members = (String[]) ArrayUtils.removeElement(members, userId);
     space.setMembers(members);
     this.updateSpace(space);
     SpaceUtils.removeUserFromGroupWithMemberMembership(userId, space.getGroupId());
     spaceLifeCycle.memberLeft(space, userId);
   }
 }
Esempio n. 6
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);
     }
   }
 }
  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();
      }
    }
  }
Esempio n. 8
0
  public void buyBrokerItem(Player player, int itemUniqueId) {
    boolean isEmptyCache = getFilteredItems(player).length == 0;
    Race playerRace = player.getCommonData().getRace();

    BrokerItem buyingItem = getRaceBrokerItems(playerRace).get(itemUniqueId);

    if (buyingItem == null) return;

    synchronized (buyingItem) {
      if (buyingItem == null || buyingItem.isSold() || buyingItem.isSettled()) {
        if (buyingItem != null && buyingItem.getItem() != null)
          PacketSendUtility.sendPacket(
              player,
              new SM_SYSTEM_MESSAGE(1300647, new DescriptionId(buyingItem.getItem().getNameID())));
        return;
      }

      if (player.getObjectId() == buyingItem.getSellerId()) {
        PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1400750));
        return;
      }

      if (player.getInventory().isFull()) {
        PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300654));
        return;
      }

      long price = buyingItem.getPrice();

      if (player.getInventory().getKinahItem().getItemCount() < price) {
        PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300759));
        return;
      }

      getRaceBrokerItems(playerRace).remove(itemUniqueId);
      putToSettled(playerRace, buyingItem, true);

      if (!isEmptyCache) {
        BrokerItem[] newCache =
            (BrokerItem[]) ArrayUtils.removeElement(getFilteredItems(player), buyingItem);
        getPlayerCache(player).setBrokerListCache(newCache);
      }

      boolean decreaseResult = player.getInventory().decreaseKinah(price);
      if (!decreaseResult) return;

      Item boughtItem = player.getInventory().putToBag(buyingItem.getItem());

      BrokerOpSaveTask bost =
          new BrokerOpSaveTask(
              buyingItem, boughtItem, player.getInventory().getKinahItem(), player.getObjectId());
      saveManager.add(bost);

      PacketSendUtility.sendPacket(player, new SM_INVENTORY_UPDATE(boughtItem, true));
      PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(boughtItem, 2));

      showRequestedItems(
          player,
          getPlayerCache(player).getBrokerMaskCache(),
          getPlayerCache(player).getBrokerSortTypeCache(),
          getPlayerCache(player).getBrokerStartPageCache());
    }
  }