Example usage for java.math BigInteger intValue

List of usage examples for java.math BigInteger intValue

Introduction

In this page you can find the example usage for java.math BigInteger intValue.

Prototype

public int intValue() 

Source Link

Document

Converts this BigInteger to an int .

Usage

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

/**
 * @see com.sun.honeycomb.adm.client.AdminClient#wipeDisk(HCDisk)
 *///from w ww  .ja  v  a2s  . c o  m
public int wipeDisk(HCDisk disk) throws MgmtException, ConnectException, PermissionException {
    if (!loggedIn())
        throw new PermissionException();
    if (null == disk)
        throw new MgmtException("Attempted to wipe nonexistent disk.");

    Object[] params = { Long.toString(this._sessionId), disk.getDiskId(), disk.getNodeId().toString() };
    this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_WIPE_DISK, params, "wipeDisk");
    BigInteger result = disk.wipe(new StatusCallback(), BigInteger.valueOf(0));
    return result.intValue();
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

/**
 * @see com.sun.honeycomb.adm.client.AdminClient#onlineDisk(HCDisk)
 *///w  w w  .  j  a va2  s.  co  m
public int onlineDisk(HCDisk disk) throws MgmtException, ConnectException, PermissionException {

    if (!loggedIn())
        throw new PermissionException();
    if (null == disk)
        throw new MgmtException("Attempted to online nonexistent disk.");

    Object[] params = { Long.toString(this._sessionId), disk.getDiskId(), disk.getNodeId().toString() };
    this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_ONLINE_DISK, params, "onlineDisk");

    BigInteger result = disk.online(new StatusCallback(), BigInteger.valueOf(0));
    return result.intValue();
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

/**
 * @see com.sun.honeycomb.adm.client.AdminClient#enableDisk(HCDisk)
 *//*from   w  w w  .ja  va 2s. co  m*/
public int enableDisk(HCDisk disk) throws MgmtException, ConnectException, PermissionException {

    if (!loggedIn())
        throw new PermissionException();
    if (null == disk)
        throw new MgmtException("Attempted to enable nonexistent disk.");

    Object[] params = { Long.toString(this._sessionId), disk.getDiskId(), disk.getNodeId().toString() };

    this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_ENABLE_DISK, params, "enableDisk");

    BigInteger result = disk.enable(new StatusCallback(), BigInteger.valueOf(0));
    return result.intValue();
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

/**
 * @see com.sun.honeycomb.adm.client.AdminClient#disableDisk(HCDisk)
 *///from   w ww . ja va  2  s . co  m
public int disableDisk(HCDisk disk) throws MgmtException, ConnectException, PermissionException {

    if (!loggedIn())
        throw new PermissionException();
    if (null == disk)
        throw new MgmtException("Attempted to disable nonexistent disk.");

    Object[] params = { Long.toString(this._sessionId), disk.getDiskId(), disk.getNodeId().toString() };
    this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_DISABLE_DISK, params, "disableDisk");

    BigInteger result = disk.disable(new StatusCallback(), BigInteger.valueOf(0));
    return result.intValue();
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

/**
 * @see com.sun.honeycomb.adm.client.AdminClient#powerNodeOn(cell,int)
 *//*from www  .  j  a va2s. c  om*/
public int powerNodeOn(HCCell cell, int nodeId) throws MgmtException, ConnectException, PermissionException {
    //
    // We are inconsistently using node nomenclature
    // sometimes nodeids are 101-116 and sometime they're
    // 0-15.
    //
    if (nodeId < 100)
        nodeId += 101;
    if (!loggedIn())
        throw new PermissionException();

    Object[] params = { Long.toString(this._sessionId), Integer.toString(nodeId),
            Integer.toString(cell.getCellId()) };
    this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_NODE_POWER_ON, params, "powerNodeOn");

    BigInteger result = cell.powerNodeOn(new StatusCallback(), BigInteger.valueOf(nodeId));
    return result.intValue();
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

/**
 *
 * @see com.sun.honeycomb.adm.client.AdminClient#powerOff(cell,boolean,boolean)
 *//*from  w  ww. j a v a  2  s .  c o m*/
public int powerOff(HCCell cell, boolean _sp, boolean _useIpmi)
        throws MgmtException, ConnectException, PermissionException {

    if (!loggedIn())
        throw new PermissionException();

    BigInteger useIpmi;
    BigInteger sp;

    if (_useIpmi) {
        useIpmi = BigInteger.valueOf(0);
    } else {
        useIpmi = BigInteger.valueOf(1);
    }

    if (_sp) {
        sp = BigInteger.valueOf(0);
    } else {
        sp = BigInteger.valueOf(1);
    }

    Object[] params = { Long.toString(this._sessionId), Byte.toString(cell.getCellId()) };
    String msgKey = AdminResourcesConstants.MSG_KEY_SHUTDOWN;
    if (_sp) {
        if (_useIpmi) {
            msgKey = AdminResourcesConstants.MSG_KEY_SHUTDOWN_ALL_IPMI;
        } else {
            msgKey = AdminResourcesConstants.MSG_KEY_SHUTDOWN_ALL;
        }
    } else if (_useIpmi) {
        msgKey = AdminResourcesConstants.MSG_KEY_SHUTDOWN_IPMI;
    }
    this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_SHUTDOWN, params, "powerOff");
    BigInteger result = cell.powerOff(new StatusCallback(), useIpmi, sp);
    return result.intValue();

}

From source file:service.actions.OrderSearch.java

private List<List<String>> getTestAdminOrderListData(Set<Long> rightBranchIds, OrderStatus status,
        List<OrderStatus> commonAvailebleStatusList, OrderSearchData searchData, User authUser, Integer start,
        Integer numberOfRecords, List<OrderStatus> rightStatusList, Boolean overdue) {

    Long starttime = System.currentTimeMillis();

    User currentUser = authManager.getCurrentUser();
    String currentDate = getCurrentDateToString();
    OrderCssManager ocm = new OrderCssManager(currentUser);
    ViewResolver vr = new ViewResolver(currentUser, branchRightsHolder);
    HashMap<Long, HashMap<String, Boolean>> br = branchRightsHolder.getBranchRights();
    HashMap<Rights, Boolean> cr = new HashMap();
    for (Rights r : Rights.values()) {
        cr.put(r, UserRightsUtil.isRight(r));
    }//from w  w w.java  2 s .  c  o  m
    List<Long> toWork = branchRightsHolder.getBranches(BranchRights.ORDER_NEW_TO_WORK);
    List<Long> toReject = branchRightsHolder.getBranches(BranchRights.ORDER_NEW_TO_REJECT);
    Authentication a = SecurityContextHolder.getContext().getAuthentication();

    SimpleDateFormat df = new SimpleDateFormat("dd/MM");
    DateFormatter fullDateFormatter = new DateFormatter();

    //LinkedHashMap<Long, HashMap> rawRes = new LinkedHashMap();
    List<List<String>> result = new ArrayList();

    List<Object[]> preRes = orderDao.getTestOrdersAndCountsForAdminBySql(rightBranchIds, status, searchData,
            authUser.getUserId(), start, numberOfRecords, rightStatusList, overdue);

    Set<Long> orderIds = new HashSet();
    for (Object[] rawOrder : preRes) {
        Long orderId = getLong(rawOrder[0]);
        orderIds.add(orderId);
    }

    HashMap<Long, List<HashMap>> otherOrders = new HashMap();
    HashMap<Long, List<HashMap>> orderDirections = new HashMap();
    HashMap<Long, List<HashMap>> orderSalaries = new HashMap();

    //log.warn("searchLogicTime1:" + Long.valueOf(System.currentTimeMillis() - starttime));

    List<Object[]> otherOrdersRawRes = orderDao.getTestOtherOrdersForAdminBySql(orderIds);
    //log.warn("searchLogicTime2:" + Long.valueOf(System.currentTimeMillis() - starttime));
    for (Object[] rawOtherOrder : otherOrdersRawRes) {
        Long orderId = getLong(rawOtherOrder[0]);

        List<HashMap> otherOrdersList = otherOrders.get(orderId);
        if (otherOrdersList == null) {
            otherOrdersList = new ArrayList();
        }
        if (otherOrdersList.size() < 5) {
            HashMap<String, Object> otherOrderData = new HashMap();

            Long otherOrderId = getLong(rawOtherOrder[1]);
            Long otherOrderBranchId = getLong(rawOtherOrder[2]);
            String otherOrderOldId = (String) rawOtherOrder[3];
            String otherOrderNumber = otherOrderOldId;
            if (otherOrderOldId == null || otherOrderOldId.equals("")) {
                otherOrderNumber = otherOrderId.toString();
            }

            otherOrderData.put("orderId", otherOrderId);
            otherOrderData.put("branchId", otherOrderBranchId);
            otherOrderData.put("number", otherOrderNumber);
            otherOrdersList.add(otherOrderData);
            otherOrders.put(orderId, otherOrdersList);
        }
    }

    List<Object[]> orderDirectionRawRes = orderDao.getTestDirectionsForAdminBySql(orderIds);
    for (Object[] rawDirectionData : orderDirectionRawRes) {
        Long orderId = getLong(rawDirectionData[0]);

        List<HashMap> directionsList = orderDirections.get(orderId);
        if (directionsList == null) {
            directionsList = new ArrayList();
        }
        HashMap<String, Object> directionData = new HashMap();

        Long directionId = getLong(rawDirectionData[1]);
        String directionName = (String) rawDirectionData[2];

        directionData.put("directionId", directionId);
        directionData.put("directionName", directionName);
        directionsList.add(directionData);
        orderDirections.put(orderId, directionsList);
    }

    List<Object[]> authorSalariesRawRes = orderDao.getTestSalariesForAdminBySql(orderIds);
    for (Object[] rawSalaryData : authorSalariesRawRes) {
        Long orderId = getLong(rawSalaryData[0]);

        List<HashMap> salaryList = orderSalaries.get(orderId);
        if (salaryList == null) {
            salaryList = new ArrayList();
        }
        HashMap<String, Object> salaryData = new HashMap();

        Double authorSalaryCost = (Double) rawSalaryData[1];
        Long authorSalaryId = getLong(rawSalaryData[2]);

        salaryData.put("salaryId", authorSalaryId);
        salaryData.put("cost", authorSalaryCost);
        salaryList.add(salaryData);
        orderSalaries.put(orderId, salaryList);
    }
    //log.warn("rawRes= "+rawRes.size());

    /*for (Map.Entry<Long, HashMap> order : rawRes.entrySet()) {
     Long orderId = order.getKey();
     HashMap orderData = order.getValue();
     List<HashMap> otherOrdersData = otherOrders.get(orderId);
     List<HashMap> directionsData = orderDirections.get(orderId);
     List<HashMap> SalaryData = orderSalaries.get(orderId);
     if (otherOrdersData == null) {
     otherOrdersData = new ArrayList();
     }
     if (directionsData == null) {
     directionsData = new ArrayList();
     }
     if (SalaryData == null) {
     SalaryData = new ArrayList();
     }
     orderData.put("otherOrders", otherOrdersData);
     orderData.put("directions", directionsData);
     orderData.put("authorSalaries", SalaryData);
            
     result.add(orderData);
     }*/
    for (Object[] rawOrder : preRes) {
        List<String> orderData = new ArrayList();
        Long orderId = getLong(rawOrder[0]);

        Date deadlineDate = (Date) rawOrder[1];
        Date realDate = (Date) rawOrder[2];
        String clientFio = (String) rawOrder[3];
        String clientPhone = (String) rawOrder[4];
        String clientEmail = (String) rawOrder[5];
        String city = (String) rawOrder[6];
        Double cost = (Double) rawOrder[7];
        Double authorSalary = (Double) rawOrder[8];
        Boolean firstFlag = (Boolean) rawOrder[9];
        Boolean secondFlag = (Boolean) rawOrder[10];
        String statusStr = (String) rawOrder[11];
        OrderStatus orderStatus = OrderStatus.valueOf(statusStr);
        Long branchId = getLong(rawOrder[12]);
        Long orderTypeId = getLong(rawOrder[13]);
        Long authorId = getLong(rawOrder[14]);
        String comment = (String) rawOrder[15];
        String authorComment = (String) rawOrder[16];
        Date readyDate = (Date) rawOrder[17];
        String commentToAuthorSalary = (String) rawOrder[18];
        Boolean unloadedInShop = (Boolean) rawOrder[19];
        Long parentOrderId = getLong(rawOrder[20]);
        Boolean selected = (Boolean) rawOrder[21];
        Boolean childSelected = (Boolean) rawOrder[22];
        Boolean statusOfUser = (Boolean) rawOrder[23];
        /*log.warn("");
         log.warn("oid:"+orderId);
         log.warn("statusOfUser:"+statusOfUser);*/

        String oldId = (String) rawOrder[24];
        String number = oldId;
        if (oldId == null || oldId.equals("")) {
            number = orderId.toString();
        }

        String subject = (String) rawOrder[25];
        Date orderDate = (Date) rawOrder[26];
        String branchName = (String) rawOrder[27];
        String abbrevation = (String) rawOrder[28];
        String orderTypeName = (String) rawOrder[29];
        String authorLogin = (String) rawOrder[30];
        String authorName = (String) rawOrder[31];
        String authorSurname = (String) rawOrder[32];

        Boolean existReject = false;

        BigInteger bi = (BigInteger) rawOrder[33];
        Integer countMess = (bi != null ? bi.intValue() : null);

        Double paymentSum = (Double) rawOrder[34];
        paymentSum = (paymentSum != null ? paymentSum : 0D);

        BigInteger countAllAuthorMess = (BigInteger) rawOrder[35];
        BigInteger countAllAdminMess = (BigInteger) rawOrder[36];
        BigInteger countNotReadyAdminMess = (BigInteger) rawOrder[37];
        BigInteger countAllDelegateMess = (BigInteger) rawOrder[38];
        BigInteger countNotReadyDelegateMess = (BigInteger) rawOrder[39];

        BigInteger countNotReadyAuthorMessages = new BigInteger("0");
        if (countMess != null) {
            countNotReadyAuthorMessages = bi;
        }
        if (countNotReadyDelegateMess != null) {
            countNotReadyAuthorMessages = countNotReadyAuthorMessages.add(countNotReadyDelegateMess);
        }

        List<OrderStatus> availableStatusList = new ArrayList(commonAvailebleStatusList);
        if (statusStr.equals(OrderStatus.NEW.name())) {
            if (!toWork.contains(branchId)) {
                availableStatusList.remove(OrderStatus.WORKING);
            }
            if (!toReject.contains(branchId)) {
                availableStatusList.remove(OrderStatus.REJECTION);
            }
        }

        List<HashMap> otherOrdersData = otherOrders.get(orderId);
        List<HashMap> directionsData = orderDirections.get(orderId);
        List<HashMap> SalaryData = orderSalaries.get(orderId);
        if (otherOrdersData == null) {
            otherOrdersData = new ArrayList();
        }
        if (directionsData == null) {
            directionsData = new ArrayList();
        }
        if (SalaryData == null) {
            SalaryData = new ArrayList();
        }

        HashMap<String, Boolean> branchRights = br.get(branchId);
        boolean rightChangeOrder = false;
        if ((childSelected == null || !childSelected) && branchRights.get("CHANGE_ORDER")
                && webPrivs.isAllowed("/Order/change", a)) {
            rightChangeOrder = true;
        }

        String rowClass = ocm.getRowClass(selected, authorId, cost, statusOfUser, orderStatus, SalaryData,
                null);

        orderData.add("<tr class=" + rowClass + ">");

        /*log.warn("sou:"+statusOfUser+";");
         log.warn("cost:"+StringAdapter.getString(cost)+";");
         if(cost!=null){
         log.warn("costcomp:"+(cost>0D)+";");
         }*/
        String col = "";
        if (cr.get(Rights.TABLE_FLAGS)) {
            col = "<td><a class='info red " + (firstFlag != null && firstFlag ? "active" : "")
                    + "' data-orderId=" + orderId + " onclick='return changeFirstFlag(this);'></a>";
            col += "<br/>";
            col += "<a class='info blue " + (secondFlag != null && secondFlag ? "active" : "")
                    + "' data-orderId=" + orderId + " onclick='return changeSecondFlag(this);'></a></td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_NUMBER)) {
            if (branchRights.get("GET_ORDER") && webPrivs.isAllowed("/Order/get", a)) {
                col = "<td><a href='#' class='orderShow flat' data-id=" + orderId + " data-number=" + number
                        + ">";
                col += "<p class='order-num'><span class='orderCount'>" + abbrevation + "</span>" + number
                        + "</p></a></td>";
            } else {
                col = "<td>" + StringAdapter.getString(number) + "</td>";
            }
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_DIRECTIONS)) {
            col = "<td class='directionsTd' data-orderId=" + orderId + ">";
            if (branchRights.get("ORDER_CHANGE_DIRECTIONS") && (childSelected == null || !childSelected)) {
                col += "<div class='directionDiv add-order-select' data-orderId=" + orderId + ">";
                for (HashMap dir : directionsData) {
                    col += "<select class='directionSelect' data-orderId=" + orderId + " data-value="
                            + dir.get("directionId") + ">";
                    col += "<option value=''></option>";
                    for (Direction d : directionService.getAll()) {
                        col += "<option value=" + d.getDirectionId() + " "
                                + (d.getDirectionId().equals(dir.get("directionId")) ? "selected" : "") + ">"
                                + d.getName() + "</option>";
                    }
                    col += "</select></br>";
                }
                col += "</div>";
                col += "<a class='add-direction addDirectionSubmit info add active' data-orderId=" + orderId
                        + ">+</a>";
            } else {
                for (HashMap d : directionsData) {
                    col += d.get("directionName");
                }
            }
            col += "</td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_TYPE)) {
            col = "<td><div class='changeDiv dbl-area-select' data-orderId=" + orderId
                    + " data-parameterName='orderType' data-isRight=" + rightChangeOrder + ">";
            col += "<div class='text'>" + orderTypeName + "</div>";
            col += "<select>";
            for (OrderType ot : orderTypeService.getAll()) {
                col += "<option value=" + ot.getOrderTypeId() + " "
                        + (ot.getOrderTypeId().equals(orderTypeId) ? "selected" : "") + ">" + ot.getName()
                        + "</option>";
            }
            col += "</select></div></td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_SUBJECT)) {
            col = "<td><div class='changeDiv dbl-area-auto' data-orderId=" + orderId
                    + " data-parameterName='subject' data-isRight=" + rightChangeOrder + ">";
            col += "<div class='text'>" + subject + "</div>";
            col += "<textarea>" + subject + "</textarea></div></td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_DATE)) {
            col = "<td><div data-fromTable='true' class='changeDiv dbl-area' data-orderId=" + orderId
                    + " data-parameterName='deadlineDate' style='width: inherit;' data-isRight="
                    + rightChangeOrder + ">";
            col += "<div style='font-size: 0.8em;'>" + (deadlineDate != null ? df.format(deadlineDate) : "")
                    + "</div>";
            col += "<input type='text' class='date' value="
                    + (deadlineDate != null ? fullDateFormatter.date(deadlineDate) : "") + "></div>";
            col += "<div data-fromTable='true' class='changeDiv dbl-area' data-orderId=" + orderId
                    + " data-parameterName='realDate' style='width: inherit;' data-isRight=" + rightChangeOrder
                    + ">";
            col += "<div style='font-size: 0.8em;'>" + (realDate != null ? df.format(realDate) : "") + "</div>";
            col += "<input type='text' class='date' value="
                    + (realDate != null ? fullDateFormatter.date(realDate) : "") + "></div></td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_CLIENT)) {
            col = "<td>";
            if (parentOrderId == null) {
                col += "<div class='changeDiv dbl-area-auto' data-orderId=" + orderId
                        + " data-parameterName='clientFio' data-isRight=" + rightChangeOrder + ">";
                col += "<div class='text'>" + clientFio + "</div>";
                col += "<input type='text' value='" + clientFio + "'></div>";
                if (branchRights.get("ORDER_SHOW_CLIENT_EMAIL") != null) {
                    col += "<div class='changeDiv dbl-area-auto' data-orderId=" + orderId
                            + " data-parameterName='clientEmail' data-isRight=" + rightChangeOrder + ">";
                    col += "<div class='text'>" + clientEmail + "</div>";
                    col += "<input type='text' value=" + clientEmail + "></div>";
                }
                if (branchRights.get("ORDER_SHOW_CLIENT_PHONE") != null) {
                    col += "<div class='changeDiv dbl-area-auto' data-orderId=" + orderId
                            + " data-parameterName='clientPhone' data-isRight=" + rightChangeOrder + ">";
                    col += "<div class='text'>" + clientPhone + "</div>";
                    col += "<input type='text' value=" + clientPhone + "></div>";
                }
                if (vr.showButtonsDivInTable(branchId, clientEmail, clientPhone)) {
                    col += "<div class='icon-contacts' style='width: 80px;'>";
                    if (vr.showSendEmailButtomInTable(branchId, clientEmail)
                            && webPrivs.isAllowed("/Notice/addEmailByClient", a)) {
                        col += "<a href='' class='mail orderEmailLink' ";
                        if (webPrivs.isAllowed("/Order/showClientEmailTitle", a)
                                && branchRights.get("ORDER_SHOW_CLIENT_EMAIL_TITLE") != null) {
                            col += " data=" + clientEmail + " title=" + clientEmail + " ";
                        }
                        col += " onclick='createWindowEmailNotice('/Notice/addEmailByClient?orderId=" + orderId
                                + "'); return false;' > </a>";
                    }
                    if (vr.showSendSmsButtomInTable(branchId, clientPhone)
                            && webPrivs.isAllowed("/Notice/addSmsByClient", a)) {
                        col += "<a href='' class='sms orderSmsLink' ";
                        if (webPrivs.isAllowed("/Order/showClientPhoneTitle", a)
                                && branchRights.get("ORDER_SHOW_CLIENT_PHONE_TITLE") != null) {
                            col += " data=" + clientPhone + " title=" + clientPhone + " ";
                        }
                        col += " onclick='createFloatWindow('/Notice/addSmsByClient?orderId=" + orderId
                                + "'); return false;' > </a>";
                    }
                }
                col += "<div class='clearfix'></div>";
                if (!otherOrdersData.isEmpty()) {
                    col += "<div class='other-order'>";
                    col += "<a class='other-title' onclick='$(this).next().toggle()'> </a>";
                    col += "<ul style='display: none;' > ";
                    for (HashMap od : otherOrdersData) {
                        if (webPrivs.isAllowed("/Order/get", a)
                                && br.get((Long) od.get("branchId")).get("GET_ORDER") != null) {
                            col += "<li><a href='#' class='orderShow' data-url='/Order/get?orderId="
                                    + od.get("orderId") + "&ajax=1' data-id=" + od.get("orderId")
                                    + " data-number=" + od.get("number") + " > #" + od.get("number")
                                    + "</a></li>";
                        }
                    }
                    col += "</ul>";
                }
            } else {
                col += "";
            }
            col += "</td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_PRICE)) {
            if (webPrivs.isAllowed("/Order/changeCost", a) && branchRights.get("ORDER_CHANGE_COST") != null) {
                col = "<td id='updatableCostTd" + orderId
                        + "' class='updatableTd dbl-area' data-type='cost' data-orderId=" + orderId + ">"
                        + (cost != null ? cost : "") + "</td>";
            } else {
                if (webPrivs.isAllowed("/Order/showCost", a) && branchRights.get("ORDER_SHOW_COST") != null) {
                    col = "<td><div class='dbl-area'>" + (cost != null ? cost : "") + "</div></td>";
                }
            }
            orderData.add(col);
        }

        String userString = authUser.getSurname() + " " + authUser.getName();
        if (cr.get(Rights.TABLE_PREPAYMENT)) {
            col = "<td>";
            if (webPrivs.isAllowed("/Payment/search", a) && branchRights.get("PAYMENT_SEARCH") != null) {
                col += "<div class='advance-payment modal-window'>";
                col += "<form id='paymentObj' onsubmit='return false;' data-orderid=" + orderId
                        + " class='add-payment-form' action='" + SystemVariables.BASE_URL
                        + "/Payment/add?ajax=true' method='post' enctype='multipart/form-data'>";
                col += "<div class='value'><span>" + paymentSum + "</span>";
                col += "<div class='modal-content'><table><tr><td class='title'>?</td><td>"
                        + userString + "</td></tr>";
                col += "<tr><td class='title'></td><td>" + (currentDate != null ? currentDate : "")
                        + "</td></tr>";
                col += "<tr><td class='title'></td><td><input id='amount' name='amount' type='text' value='' autocomplete='off'></td></tr>";
                col += "<tr><td class='title'>C?<br/></td><td><select id='paymentType' name='paymentType'>";
                for (PaymentType pt : paymentTypeService.getActive()) {
                    col += "<option value=" + pt.getId() + ">" + pt.getName() + "</option>";
                }
                col += "</select></td></tr>";
                col += "<tr><td colspan='2'><div class='uploadify-button' data-id=" + orderId
                        + " data-num='0' style='width: 50%;'> </div><input name='file' type='file' class='hidden ajaxUpload' id='fileInput"
                        + orderId + "' data-id=" + orderId + " data-num='0'></td></tr>";
                col += "</table><br/><input type='hidden' name='orderId' value=" + orderId + " />";
                col += "<input type='submit' class='modal-close' value=''></div></div></form></div>";
            }
            col += "</td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_AUTHOR_SALARY)) {
            if (webPrivs.isAllowed("/Order/changeAuthorSalary", a)
                    && branchRights.get("ORDER_CHANGE_AUTHOR_SALARY") != null) {
                col = "<td class='author-salary dbl-area' data-orderId=" + orderId + ">";
                col += "<div class='value-area "
                        + (commentToAuthorSalary != null && !commentToAuthorSalary.equals("") ? "warning" : "")
                        + "'>" + (authorSalary != null ? authorSalary : "") + "</div>";
                col += "<div class='input-area' style='display: none;' >";
                col += "<input class='author-salary-input' type='text' name='authorSalary' value="
                        + (authorSalary != null ? authorSalary : "") + ">";
                col += "<textarea class='comment-salary-input' >"
                        + (commentToAuthorSalary != null ? commentToAuthorSalary : "")
                        + "</textarea></div></td>";
            } else {
                col = "<td>" + (authorSalary != null ? authorSalary : "") + "</td>";
            }
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_STATUS)) {
            col = "<td class=" + ocm.getStatusClass(statusStr, cost, paymentSum)
                    + "><div class='dbl-area-select color' >";
            if (webPrivs.isAllowed("/Order/changeStatus", a)
                    && webPrivs.isAllowed("/Order/changeStatusFromTable", a)
                    && branchRights.get("ORDER_CHANGE_STATUS") != null
                    && branchRights.get("ORDER_CHANGE_STATUS_FROM_TABLE") != null) {
                col += "<div class='status-in-table text order-status' id='statusDiv" + orderId + "' >"
                        + vr.getStatusName(orderStatus, existReject, cost, statusOfUser) + "</div>";
                col += "<select id='statuSelect" + orderId + "' data-orderId=" + orderId
                        + " class='statusSelect' name='status'>";
                for (OrderStatus os : availableStatusList) {
                    col += "<option value=" + os.toString() + " " + (os.equals(orderStatus) ? "selected" : "")
                            + " >" + os.getName() + "</option>";
                }
                col += "</select>";
            } else {
                col += "<div class='text'>" + vr.getStatusName(orderStatus, existReject, cost, statusOfUser)
                        + "</div>";
            }
            col += "</div></td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_AUTHOR)) {
            col = "<td>";
            if (vr.allowShowAuthor()) {
                col += vr.getAuthorParams(authorId, authorSurname, authorName, authorLogin, branchId, "<br/>");
            }
            col += "</td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_AUTHOR_MESSAGE)) {
            col = "<td>";
            if (!countNotReadyAuthorMessages.equals(BigInteger.valueOf(0L))) {
                col += "<p class='circle'>" + countNotReadyAuthorMessages + "</p>";
            } else {
                col += "(" + countAllAuthorMess + ")";
            }
            col += "<br/>";
            if (orderStatus != null && orderStatus.equals(OrderStatus.NEW)) {
                for (HashMap sal : SalaryData) {
                    col += "<br/> " + sal.get("cost");
                }
            }
            col += "</td>";
            orderData.add(col);
        }

        if (cr.get(Rights.TABLE_ADMIN_MESSAGE)) {
            col = "<td>";
            if (!countNotReadyAdminMess.equals(BigInteger.valueOf(0L))) {
                col += "<p class='circle'>" + countNotReadyAdminMess + "</p>";
            } else {
                col += "(" + countAllAdminMess + ")";
            }
            if (unloadedInShop != null && unloadedInShop) {
                col += "<br/><span class='info check'></span>";
            }
            col += "</td>";
            orderData.add(col);
        }

        orderData.add("</tr>");

        result.add(orderData);
    }

    //log.warn("searchLogicTime:" + Long.valueOf(System.currentTimeMillis() - starttime));

    return result;
}

From source file:com.openkm.cmis.CmisRepository.java

/**
 * CMIS getChildren.//from   w  w  w  .j av a2s.c om
 */
public ObjectInFolderList getChildren(CallContext context, String folderId, String filter,
        Boolean includeAllowableActions, Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount,
        ObjectInfoHandler objectInfos) {
    log.debug("getChildren({})", folderId);

    // split filter
    Set<String> filterCollection = splitFilter(filter);

    // set defaults if values not set
    boolean iaa = (includeAllowableActions == null ? false : includeAllowableActions.booleanValue());
    boolean ips = (includePathSegment == null ? false : includePathSegment.booleanValue());

    // skip and max
    int skip = (skipCount == null ? 0 : skipCount.intValue());
    if (skip < 0) {
        skip = 0;
    }

    int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
    if (max < 0) {
        max = Integer.MAX_VALUE;
    }

    try {
        if (!OKMFolder.getInstance().isValid(null, folderId)) {
            throw new CmisObjectNotFoundException("Not a folder!");
        }

        // get the folder
        Folder fld = OKMFolder.getInstance().getProperties(null, folderId);

        // set object info of the the folder
        if (context.isObjectInfoRequired()) {
            compileObjectType(context, fld, null, false, false, objectInfos);
        }

        // prepare result
        ObjectInFolderListImpl result = new ObjectInFolderListImpl();
        result.setObjects(new ArrayList<ObjectInFolderData>());
        result.setHasMoreItems(false);
        int count = 0;

        // iterate through children (folders)
        for (Folder child : OKMFolder.getInstance().getChildren(null, fld.getPath())) {
            count++;

            if (skip > 0) {
                skip--;
                continue;
            }

            if (result.getObjects().size() >= max) {
                result.setHasMoreItems(true);
                continue;
            }

            // build and add child object
            ObjectInFolderDataImpl objectInFolder = new ObjectInFolderDataImpl();
            objectInFolder
                    .setObject(compileObjectType(context, child, filterCollection, iaa, false, objectInfos));

            if (ips) {
                objectInFolder.setPathSegment(PathUtils.getName(child.getPath()));
            }

            result.getObjects().add(objectInFolder);
        }

        // iterate through children (documents)
        for (Document child : OKMDocument.getInstance().getChildren(null, fld.getPath())) {
            count++;

            if (skip > 0) {
                skip--;
                continue;
            }

            if (result.getObjects().size() >= max) {
                result.setHasMoreItems(true);
                continue;
            }

            // build and add child object
            ObjectInFolderDataImpl objectInFolder = new ObjectInFolderDataImpl();
            objectInFolder
                    .setObject(compileObjectType(context, child, filterCollection, iaa, false, objectInfos));

            if (ips) {
                objectInFolder.setPathSegment(PathUtils.getName(child.getPath()));
            }

            result.getObjects().add(objectInFolder);
        }

        result.setNumItems(BigInteger.valueOf(count));
        return result;
    } catch (PathNotFoundException e) {
        throw new CmisObjectNotFoundException(e.getMessage(), e);
    } catch (RepositoryException e) {
        throw new CmisStorageException(e.getMessage(), e);
    } catch (DatabaseException e) {
        throw new CmisStorageException(e.getMessage(), e);
    }
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

private boolean login() throws MgmtException, ConnectException, PermissionException {
    if (_sessionId == AdminClient.NOT_LOGGED_IN_SESSION_ID) {
        Date now = new Date();
        BigInteger loginResult = getSilo(SiloInfo.getInstance().getSiloUrl())
                .login(BigInteger.valueOf(now.getTime()));
        switch (loginResult.intValue()) {
        case CliConstants.MGMT_OK:
            _sessionId = now.getTime();//from  w  ww. j  a  va 2 s . com
            _lastChecked = now;
            Object[] params = { Long.toString(_sessionId) };
            this.extLog(ExtLevel.EXT_INFO, AdminResourcesConstants.MSG_KEY_LOGIN, params, "login");
            this._cachedCellId = this.getMasterCellId();
            getAuditLogger();
            return true;

        case CliConstants.MGMT_ALREADY_LOGGED:
            return false;

        case CliConstants.MGMT_NOT_MASTER_CELL:
            throw new PermissionException("Need to log on the master " + "cell to perform this command");
        default:
            throw new RuntimeException("Unexpected error code from server");
        }
    } else {
        return loggedIn();
    }
}

From source file:org.eclipse.ecr.opencmis.impl.server.NuxeoCmisService.java

@Override
public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogTokenHolder,
        Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeAcl,
        BigInteger maxItems, ExtensionsData extension) {
    if (changeLogTokenHolder == null) {
        throw new CmisInvalidArgumentException("Missing change log token holder");

    }/*from  w  ww . java  2  s. c om*/
    String changeLogToken = changeLogTokenHolder.getValue();
    long minDate;
    if (changeLogToken == null) {
        minDate = 0;
    } else {
        try {
            minDate = Long.parseLong(changeLogToken);
        } catch (NumberFormatException e) {
            throw new CmisInvalidArgumentException("Invalid change log token");
        }
    }
    try {
        AuditReader reader = Framework.getService(AuditReader.class);
        if (reader == null) {
            throw new CmisRuntimeException("Cannot find audit service");
        }
        int max = maxItems == null ? -1 : maxItems.intValue();
        if (max < 0) {
            max = DEFAULT_CHANGE_LOG_SIZE;
        }
        // TODO XXX repositoryId as well
        Map<String, Object> params = new HashMap<String, Object>();
        String query = "FROM LogEntry log" //
                + " WHERE log.eventDate >= :minDate" //
                + "   AND log.eventId IN (:evCreated, :evModified, :evRemoved)" //
                + " ORDER BY log.eventDate";
        params.put("minDate", new Date(minDate));
        params.put("evCreated", DocumentEventTypes.DOCUMENT_CREATED);
        params.put("evModified", DocumentEventTypes.DOCUMENT_UPDATED);
        params.put("evRemoved", DocumentEventTypes.DOCUMENT_REMOVED);
        List<?> entries = reader.nativeQuery(query, params, 1, max + 1);
        ObjectListImpl ol = new ObjectListImpl();
        boolean hasMoreItems = entries.size() > max;
        ol.setHasMoreItems(Boolean.valueOf(hasMoreItems));
        if (hasMoreItems) {
            entries = entries.subList(0, max);
        }
        List<ObjectData> ods = new ArrayList<ObjectData>(entries.size());
        Date date = null;
        for (Object entry : entries) {
            LogEntry logEntry = (LogEntry) entry;
            ObjectDataImpl od = new ObjectDataImpl();
            ChangeEventInfoDataImpl cei = new ChangeEventInfoDataImpl();
            // change type
            String eventId = logEntry.getEventId();
            ChangeType changeType;
            if (DocumentEventTypes.DOCUMENT_CREATED.equals(eventId)) {
                changeType = ChangeType.CREATED;
            } else if (DocumentEventTypes.DOCUMENT_UPDATED.equals(eventId)) {
                changeType = ChangeType.UPDATED;
            } else if (DocumentEventTypes.DOCUMENT_REMOVED.equals(eventId)) {
                changeType = ChangeType.DELETED;
            } else {
                continue;
            }
            cei.setChangeType(changeType);
            // change time
            GregorianCalendar changeTime = (GregorianCalendar) Calendar.getInstance();
            date = logEntry.getEventDate();
            changeTime.setTime(date);
            cei.setChangeTime(changeTime);
            od.setChangeEventInfo(cei);
            // properties: id, doc type
            PropertiesImpl properties = new PropertiesImpl();
            properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_ID, logEntry.getDocUUID()));
            properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, logEntry.getDocType()));
            od.setProperties(properties);
            ods.add(od);
        }
        ol.setObjects(ods);
        ol.setNumItems(BigInteger.valueOf(-1));
        String latestChangeLogToken = date == null ? null : String.valueOf(date.getTime());
        changeLogTokenHolder.setValue(latestChangeLogToken);
        return ol;
    } catch (Exception e) {
        throw new CmisRuntimeException(e.toString(), e);
    }
}