Esempio n. 1
0
  @SuppressWarnings("unchecked")
  public void redrawPanelFromXml(String xmlstr) {
    try {
      JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();
      JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlstr);
      ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
      BodyType bt = messageType.getMessageBody();
      MasterResponseType masterResponseType =
          (MasterResponseType)
              new JAXBUnWrapHelper().getObjectByClass(bt.getAny(), MasterResponseType.class);
      RequestXmlType requestXmlType = masterResponseType.getQueryMaster().get(0).getRequestXml();
      String strRequest = (String) requestXmlType.getContent().get(0);

      jaxbElement = jaxbUtil.unMashallFromString(strRequest);
      RequestMessageType requestMessageType = (RequestMessageType) jaxbElement.getValue();
      bt = requestMessageType.getMessageBody();
      QueryDefinitionRequestType queryDefinitionRequestType =
          (QueryDefinitionRequestType)
              new JAXBUnWrapHelper()
                  .getObjectByClass(bt.getAny(), QueryDefinitionRequestType.class);
      QueryDefinitionType queryDefinitionType = queryDefinitionRequestType.getQueryDefinition();

      int numOfPanels = queryDefinitionType.getPanel().size();
      if (numOfPanels > 3) {
        for (int i = 0; i < (numOfPanels - 3); i++) {
          topPanel.addPanel();
        }
      }

      for (int i = 0; i < numOfPanels; i++) {
        PanelType panelType = queryDefinitionType.getPanel().get(i);
        final ConceptTreePanel panel = getTreePanel(i);
        ConceptTreeData panelData = new ConceptTreeData();
        panelData.setOccurrenceTimes(panelType.getTotalItemOccurrences().getValue());
        if (panelType.getInvert() == 0) {
          panelData.exclude(false);
        } else if (panelType.getInvert() == 1) {
          panelData.exclude(true);
        }

        for (int j = 0; j < panelType.getItem().size(); j++) {
          ItemType itemType = panelType.getItem().get(j);
          QueryConceptTreeNodeData nodedata = new QueryConceptTreeNodeData();

          nodedata.name(itemType.getItemName());
          nodedata.visualAttribute("FA");
          nodedata.tooltip(itemType.getTooltip());
          nodedata.fullname(itemType.getItemKey());
          // mm removed
          // nodedata.lookuptable(itemType.getItemTable());
          nodedata.hlevel(new Integer(itemType.getHlevel()).toString());
          nodedata.lookupdb("metadata");
          // nodedata.selectservice(System.getProperty("selectservice")
          // );
          // get the xml content from select service then set it as
          // node data
          nodedata.setXmlContent();

          panelData.getItems().add(nodedata);
        }

        final ConceptTreeData fpanelData = panelData;
        final String name = queryDefinitionType.getQueryName();
        java.awt.EventQueue.invokeLater(
            new Runnable() {
              public void run() {
                topPanel.setQueryName(name);
                panel.redraw(fpanelData);
              }
            });
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public List<Item> fetchItemForHoldings(int holdingsId) throws Exception {
    List<Item> itemList = new ArrayList<Item>();
    Map<String, Item> itemHashMap = new HashMap<>();
    itemPreparedStatement.setInt(1, holdingsId);
    ResultSet resultSet = itemPreparedStatement.executeQuery();
    Set<String> highDensityStorageSet = null;
    Set<String> donorNoteSet = null;
    Set<String> itemNoteSet = null;
    Set<String> statisticalSearchSet = null;
    org.kuali.ole.docstore.common.document.content.instance.Item itemObj = null;

    while (resultSet.next()) {
      String id = resultSet.getString("ITEM_ID");
      if (itemHashMap.containsKey(id)) {
        itemObj =
            (org.kuali.ole.docstore.common.document.content.instance.Item)
                itemHashMap.get(id).getContentObject();
      } else {
        itemObj = new org.kuali.ole.docstore.common.document.content.instance.Item();
        Item item = new Item();
        itemList.add(item);
        item.setId("wio-" + resultSet.getString("ITEM_ID"));
        item.setContentObject(itemObj);
        Location location =
            getLocationDetails(
                resultSet.getString("LOCATION"), resultSet.getString("LOCATION_LEVEL"));
        itemObj.setLocation(location);
        CallNumber callNumber = new CallNumber();
        callNumber.setNumber(resultSet.getString("CALL_NUMBER"));
        callNumber.setPrefix(resultSet.getString("CALL_NUMBER_PREFIX"));
        ShelvingOrder shelvingOrder = new ShelvingOrder();
        if (resultSet.getString("SHELVING_ORDER") != null
            && !"null".equals(resultSet.getString("SHELVING_ORDER"))) {
          shelvingOrder.setCodeValue(resultSet.getString("SHELVING_ORDER"));
          shelvingOrder.setFullValue(resultSet.getString("SHELVING_ORDER"));
        }
        callNumber.setShelvingOrder(shelvingOrder);
        ShelvingScheme shelvingScheme = new ShelvingScheme();
        if (callNumberType.get(resultSet.getString("CALL_NUMBER_TYPE_ID")) != null) {
          String[] strings =
              callNumberType.get(resultSet.getString("CALL_NUMBER_TYPE_ID")).split("[|]");
          shelvingScheme.setCodeValue(strings[0]);
          shelvingScheme.setFullValue(strings[1]);
        }
        callNumber.setShelvingScheme(shelvingScheme);
        itemObj.setCallNumber(callNumber);
        itemObj.setBarcodeARSL(resultSet.getString("BARCODE_ARSL"));
        itemObj.setEnumeration(resultSet.getString("ENUMERATION"));
        itemObj.setChronology(resultSet.getString("CHRONOLOGY"));
        itemObj.setCopyNumber(resultSet.getString("COPY_NUMBER"));
        AccessInformation accessInformation = new AccessInformation();
        accessInformation.setBarcode(resultSet.getString("BARCODE"));
        Uri uri = new Uri();
        uri.setValue(resultSet.getString("URI"));
        accessInformation.setUri(uri);
        itemObj.setAccessInformation(accessInformation);
        itemObj.setPurchaseOrderLineItemIdentifier(
            resultSet.getString("PURCHASE_ORDER_LINE_ITEM_ID"));
        itemObj.setVendorLineItemIdentifier(resultSet.getString("VENDOR_LINE_ITEM_ID"));
        itemObj.setFund(resultSet.getString("FUND"));
        itemObj.setPrice(resultSet.getString("PRICE"));
        itemObj.setItemStatusEffectiveDate(
            convertDateFormat(resultSet.getString("ITEM_STATUS_DATE_UPDATED")));
        if (resultSet.getString("FAST_ADD") != null) {
          itemObj.setFastAddFlag(
              resultSet.getString("FAST_ADD").equalsIgnoreCase("Y") ? Boolean.TRUE : Boolean.FALSE);
        }
        itemObj.setCheckinNote(resultSet.getString("CHECK_IN_NOTE"));
        if (resultSet.getString("CLAIMS_RETURNED") != null) {
          itemObj.setClaimsReturnedFlag(
              resultSet.getString("CLAIMS_RETURNED").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE);
        }
        String claimsReturnFlagCreatedDate = resultSet.getString("CLAIMS_RETURNED_DATE_CREATED");
        itemObj.setClaimsReturnedFlagCreateDate(convertDateFormat(claimsReturnFlagCreatedDate));
        itemObj.setClaimsReturnedNote(resultSet.getString("CLAIMS_RETURNED_NOTE"));
        itemObj.setCurrentBorrower(resultSet.getString("CURRENT_BORROWER"));
        itemObj.setProxyBorrower(resultSet.getString("PROXY_BORROWER"));
        String dueDateTime = resultSet.getString("DUE_DATE_TIME");
        itemObj.setDueDateTime(convertDateFormat(dueDateTime));
        String originalDueDate = resultSet.getString("ORG_DUE_DATE_TIME");
        itemObj.setOriginalDueDate(convertDateFormat(originalDueDate));
        String checkOutDateTime = resultSet.getString("CHECK_OUT_DATE_TIME");
        itemObj.setCheckOutDateTime(convertDateFormat(checkOutDateTime));
        itemObj.setDamagedItemNote(resultSet.getString("ITEM_DAMAGED_NOTE"));
        if (resultSet.getString("ITEM_DAMAGED_STATUS") != null) {
          itemObj.setItemDamagedStatus(
              resultSet.getString("ITEM_DAMAGED_STATUS").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE);
        }
        if (resultSet.getString("MISSING_PIECES") != null) {
          itemObj.setMissingPieceFlag(
              resultSet.getString("MISSING_PIECES").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE);
        }
        itemObj.setMissingPiecesCount(resultSet.getString("MISSING_PIECES_COUNT"));
        itemObj.setMissingPieceFlagNote(resultSet.getString("MISSING_PIECES_NOTE"));
        itemObj.setMissingPieceEffectiveDate(resultSet.getString("MISSING_PIECES_EFFECTIVE_DATE"));
        itemObj.setNumberOfPieces(resultSet.getString("NUM_PIECES"));
        itemObj.setDescriptionOfPieces(resultSet.getString("DESC_OF_PIECES"));
        itemObj.setNumberOfRenew(resultSet.getInt("NUM_OF_RENEW"));
        highDensityStorageSet = new HashSet<>();
        itemNoteSet = new HashSet<>();
        statisticalSearchSet = new HashSet<>();
        donorNoteSet = new HashSet<>();

        ItemStatus itemStatus = new ItemStatus();
        if (itemStatusMap.containsKey(resultSet.getString("ITEM_STATUS_ID"))) {
          String[] strings = itemStatusMap.get(resultSet.getString("ITEM_STATUS_ID")).split("[|]");
          itemStatus.setCodeValue(strings[0]);
          itemStatus.setFullValue(strings[1]);
        }

        itemObj.setItemStatus(itemStatus);
        ItemType itemType = new ItemType();
        if (itemTypeMap.containsKey(resultSet.getString("ITEM_TYPE_ID"))) {
          String[] strings = itemTypeMap.get(resultSet.getString("ITEM_TYPE_ID")).split("[|]");
          itemType.setCodeValue(strings[0]);
          itemType.setFullValue(strings[1]);
        }
        itemObj.setItemType(itemType);
        ItemType tempItemType = new ItemType();
        if (itemTypeMap.containsKey(resultSet.getString("TEMP_ITEM_TYPE_ID"))) {
          String[] strings = itemTypeMap.get(resultSet.getString("TEMP_ITEM_TYPE_ID")).split("[|]");
          tempItemType.setCodeValue(strings[0]);
          tempItemType.setFullValue(strings[1]);
        }
        itemObj.setTemporaryItemType(tempItemType);
        item.setContentObject(itemObj);
        item.setCreatedBy(resultSet.getString("CREATED_BY"));
        item.setCreatedOn(resultSet.getString("DATE_CREATED"));
        if (resultSet.getString("STAFF_ONLY") != null) {
          item.setStaffOnly(
              (resultSet.getString("STAFF_ONLY").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE));
        }
        item.setUpdatedBy(resultSet.getString("UPDATED_BY"));
        item.setUpdatedOn(resultSet.getString("DATE_UPDATED"));
        item.setLastUpdated(resultSet.getString("DATE_UPDATED"));
      }
      if (itemNoteSet.add(resultSet.getString("ITEM_NOTE_ID"))) {
        Note note = new Note();
        note.setValue(resultSet.getString("NOTE"));
        note.setType(resultSet.getString("TYPE"));
        itemObj.getNote().add(note);
      }
      if (resultSet.getString("STAT_SEARCH_CODE_ID") != null
          && statisticalSearchSet.add(resultSet.getString("STAT_SEARCH_CODE_ID"))) {
        String[] strings =
            statisticalSearchCodeMap.get(resultSet.getString("STAT_SEARCH_CODE_ID")).split("[|]");
        StatisticalSearchingCode statisticalSearchingCode = new StatisticalSearchingCode();
        statisticalSearchingCode.setCodeValue(strings[0]);
        statisticalSearchingCode.setFullValue(strings[1]);
        itemObj.getStatisticalSearchingCode().add(statisticalSearchingCode);
      }
      if (donorNoteSet.add(resultSet.getString("ITEM_DONOR_ID"))) {
        DonorInfo donorInfo = new DonorInfo();
        donorInfo.setDonorCode(resultSet.getString("DONOR_CODE"));
        donorInfo.setDonorNote(resultSet.getString("DONOR_NOTE"));
        donorInfo.setDonorPublicDisplay(resultSet.getString("DONOR_DISPLAY_NOTE"));
        itemObj.getDonorInfo().add(donorInfo);
      }
      if (highDensityStorageSet.add(resultSet.getString("ITEM_DONOR_ID"))) {
        HighDensityStorage highDensityStorage = new HighDensityStorage();
        highDensityStorage.setRow(resultSet.getString("HIGH_DENSITY_ROW"));
        itemObj.setHighDensityStorage(highDensityStorage);
      }
    }
    resultSet.close();
    return itemList;
  }
Esempio n. 3
0
  public String wirteQueryXML() {
    DTOFactory dtoFactory = new DTOFactory();
    // TimeZone pdt = TimeZone.getTimeZone("EST");
    // DatatypeFactory dataTypeFactory = null;
    // try {
    // dataTypeFactory = DatatypeFactory.newInstance();
    // XMLGregorianCalendar xmlCalendar =
    // dataTypeFactory.newXMLGregorianCalendarDate(2006, 9, 21, -5*60);
    // TimeZone pdt = xmlCalendar.getgetTimezone();
    // }
    // catch (DatatypeConfigurationException e) {
    // e.printStackTrace();
    // }

    // RequestType requestType = new RequestType();
    // requestType.setSpecificityScale(specificity());
    QueryDefinitionType queryDefinitionType = new QueryDefinitionType();
    QueryDefinitionRequestType queryDefinitionRequestType = new QueryDefinitionRequestType();
    for (int i = 0; i < panelCount; i++) {
      ConceptTreePanel panel = getTreePanel(i);
      ArrayList<QueryConceptTreeNodeData> nodelist = panel.data().getItems();
      if ((nodelist != null) && (nodelist.size() > 0)) {
        System.out.println(
            "Panel: "
                + panel.getGroupName()
                + " Excluded: "
                + ((panel.data().exclude()) ? "yes" : "no"));
        PanelType panelType = new PanelType();
        panelType.setInvert((panel.data().exclude()) ? 1 : 0);
        PanelType.TotalItemOccurrences totalItemOccurrences = new PanelType.TotalItemOccurrences();
        totalItemOccurrences.setValue(panel.getOccurrenceTimes());

        panelType.setTotalItemOccurrences(totalItemOccurrences);
        panelType.setPanelNumber(i + 1);

        // if(panel.data().startTime() != -1) {
        // panelType.setPanelDateFrom(//dataTypeFactory.
        // newXMLGregorianCalendarDate(
        // dtoFactory.getXMLGregorianCalendarDate(panel.data().startYear(
        // ),
        // panel.data().startMonth(), panel.data().startDay()));
        // }

        // if(panel.data().endTime() != -1) {
        // panelType.setPanelDateTo(//dataTypeFactory.
        // newXMLGregorianCalendarDate(
        // dtoFactory.getXMLGregorianCalendarDate(panel.data().endYear(),
        // panel.data().endMonth(), panel.data().endDay()));
        // }

        for (int j = 0; j < nodelist.size(); j++) {
          QueryConceptTreeNodeData node = nodelist.get(j);
          System.out.println("\tItem: " + node.fullname());

          // create item
          ItemType itemType = new ItemType();
          // itemType.setConstrainByDate(.setDateFrom(dtoFactory.
          // getXMLGregorianCalendarDate(2006,
          // 10, 4)));
          itemType.setItemKey(node.fullname());
          itemType.setItemName(node.name());
          // mm removed
          // itemType.setItemTable(node.lookuptable());
          itemType.setTooltip(node.tooltip());
          itemType.setHlevel(Integer.parseInt(node.hlevel()));
          itemType.setClazz("ENC");
          ConstrainByDate cDate = new ConstrainByDate();
          ConstrainDateType constrinDataType = new ConstrainDateType();
          constrinDataType.setValue(
              dtoFactory.getXMLGregorianCalendarDate(
                  node.startYear(), node.startMonth(), node.startDay()));
          if (node.startTime() != -1) {
            cDate.setDateFrom(constrinDataType);
          }
          if (node.endTime() != -1) {
            cDate.setDateTo(constrinDataType);
          }
          itemType.getConstrainByDate().add(cDate);
          panelType.getItem().add(itemType);
        }
        queryDefinitionType.getPanel().add(panelType);
      }
    }

    // create infotype
    InfoType infoType = new InfoType();
    infoType.setValue("INFO");
    infoType.setUrl("http://www.ibm.com");

    // create header
    PsmQryHeaderType headerType = new PsmQryHeaderType();
    UserType userType = new UserType();
    userType.setLogin(UserInfoBean.getInstance().getUserName());
    userType.setValue(UserInfoBean.getInstance().getUserName());
    headerType.setUser(userType);
    headerType.setRequestType(PsmRequestTypeType.CRC_QRY_RUN_QUERY_INSTANCE_FROM_QUERY_DEFINITION);
    if (queryName == null) {
      queryName =
          getTreePanel(0).data().getItems().get(0).name()
              + "_"
              + generateMessageId().substring(0, 4);
    }

    queryDefinitionType.setQueryName(queryName);
    queryDefinitionRequestType.setQueryDefinition(queryDefinitionType);

    RequestHeaderType requestHeader = new RequestHeaderType();
    requestHeader.setResultWaittimeMs(180000);

    BodyType bodyType = new BodyType();
    edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory psmOf =
        new edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory();
    bodyType.getAny().add(psmOf.createPsmheader(headerType));
    bodyType.getAny().add(psmOf.createRequest(queryDefinitionRequestType));
    // new QueryToolDTOFactory().buildBodyType(headerType,
    // queryDefinitionRequestType, null);
    MessageHeaderType messageHeader = getMessageHeader();
    RequestMessageType requestMessageType = new RequestMessageType();
    requestMessageType.setMessageBody(bodyType);
    requestMessageType.setMessageHeader(messageHeader);
    requestMessageType.setRequestHeader(requestHeader);
    // dtoFactory.getRequestMessageType(messageHeader, requestHeader,
    // bodyType);

    JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();
    StringWriter strWriter = new StringWriter();
    try {
      edu.harvard.i2b2.crcxmljaxb.datavo.i2b2message.ObjectFactory of =
          new edu.harvard.i2b2.crcxmljaxb.datavo.i2b2message.ObjectFactory();
      jaxbUtil.marshaller(of.createRequest(requestMessageType), strWriter);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return strWriter.toString();
  }