Пример #1
0
  private List generateHoldings(Record storageRecord) {
    List result = new ArrayList();
    EntityObject wd = dataEntryService.findDefaultHoldingWorksheetFast(storageRecord);

    List holdDataFields = MarcUtils.getVaribleFieldList(storageRecord, "999");
    for (int i = 0; i < holdDataFields.size(); i++) {
      DataField hold = (DataField) holdDataFields.get(i);
      String locCode = MarcUtils.getSubfieldData(hold, 's', 0);
      locCode = StringUtils.extendedArabicToLatinDigit(locCode);
      ConstantTableItem location = findOrCreateLocationByCode(locCode);
      if (location == null) {
        continue;
      }
      String regNo = MarcUtils.getSubfieldData(hold, 'r', 0);
      if (regNo == null || regNo.length() == 0) {
        continue;
      }
      String vol = MarcUtils.getSubfieldData(hold, 'v', 0);
      String copy = MarcUtils.getSubfieldData(hold, 'c', 0);
      String part = MarcUtils.getSubfieldData(hold, 'p', 0);

      Record marc =
          dataEntryService.createPreparedRegisterRecordFast(
              Register.class, storageRecord, location, AppSession.getInstance().getCurrentUser());

      DataField df = ensureFieldExists(marc, Tags.HOL_LOC_CALL_NO);
      MarcUtils.setSubfieldData(df, 'b', locCode);
      MarcUtils.setSubfieldData(df, 'm', regNo);

      df = (DataField) ensureFieldExists(marc, Tags.HOL_COPY_VOL_INFO);
      MarcUtils.setSubfieldData(df, 'a', vol);
      MarcUtils.setSubfieldData(df, 'b', copy);
      MarcUtils.setSubfieldData(df, 'c', part);

      Register reg = new Register();
      reg.setRegNo(regNo);
      reg.setVolume(vol);
      reg.setCopy(copy);
      reg.setLocation(location);
      if (wd != null) reg.setWorksheetDefinitionId(wd.getId());
      reg.setContent(MarcUtils.marshalContent(marc));

      //			reg.setBibliographicRecord(storageRecord);
      //			storageRecord.getRegisters().add(reg);
      result.add(reg);
      storageRecord.getDataFieldList().remove(hold);
    }
    return result;
    // remove 999 fields
    //		  for (Iterator iter = storageRecord.getDataFieldList().iterator(); iter.hasNext();) {
    //			DataField element = (DataField) iter.next();
    //			if ("999".equals(element.getTag()))
    //				iter.remove();
    //		  }

  }
Пример #2
0
  private void fillWrappedObject(LoanedItem loanedItem) {

    this.setFromDate(DateFormat.getDefaultInstance(locale).format(loanedItem.getFromDate()));
    this.setToDate(DateFormat.getDefaultInstance(locale).format(loanedItem.getToDate()));

    Register register = loanedItem.getRegister();
    BibliographicRecord bibliographicRecord = register.getBibliographicRecord();

    this.setBiblioMainEntry(bibliographicRecord.getMainEntry());
    this.biblioPublisher = bibliographicRecord.getPublisherName();
    this.biblioPublishDate = bibliographicRecord.getPublishDate();
    this.biblioLcClass = bibliographicRecord.getLCClass();
    this.biblioDeClass = bibliographicRecord.getDEClass();
    this.biblioNlmClass = bibliographicRecord.getNLMClass();
    this.biblioCallNumber = bibliographicRecord.getCallNumber();
    this.biblioNativeCallNumber = bibliographicRecord.getNativeCallNumber();
    this.gmdType = bibliographicRecord.getGmdText();

    this.setBiblioTitle(bibliographicRecord.getTitle());
    this.setRegisterNumberType(register.getRegNo());
    this.setRetriveNoLabel(register.getRetriveNo());
    this.setVolume(register.getVolume());
    this.setSectionAddress(register.getAddress());
    this.setLocQualifier(register.getLocationQualifier());
    this.setDocumentCopy(register.getCopy());
    //         if (loanHistory.getLoanRequest() != null) {
    int loanType = loanedItem.getLoanStatus();
    if (loanType == LoanedItem.ORDINARY_LOAN) {
      this.setLoanType(MessageFactory.getInstance().getMessage("loan.ordinary").getSummary());
    } else if (loanType == LoanedItem.HOURLY_LOAN) {
      this.setLoanType(MessageFactory.getInstance().getMessage("loan.hourly").getSummary());
    }
    //         }

    LoanProfileView loanProfileView = loanedItem.getLoanProfileView();
    this.setProfileTitle(loanProfileView.getMemberTitle());
    this.setMembershipNumber(loanProfileView.getMembershipNo());
    this.loanStatus = loanedItem.getLoanStatus();
    this.lender = loanedItem.getLender().getTitle();
    this.holdingLocation = register.getLocation().getItemName();
    int interval = DateUtils.calculateDateInterval(loanedItem.getToDate(), new Date(), true) - 1;
    if (interval > 0) {
      this.setDelayDays(String.valueOf(interval));
    }
    this.setComments(loanedItem.getLoanRequest().getComments());
  }
  public void onPoll(PollEvent event) {
    try {
      final boolean isLeftToRight = registerBean.isLeftToRight();
      final Register currentRecord = registerBean.getCurrentRecord();
      final String servicePolicy = registerBean.getServicePolicy();
      final String acquisitionStatus = registerBean.getAcquisitionStatus();
      final StorageContainer.NodeIterator regList = registerBean.getRegList();

      if (regList.hasNext()) {
        String registerNo = (String) regList.next();
        registerNo =
            (isLeftToRight)
                ? StringUtils.extendedArabicToLatinDigit(registerNo)
                : StringUtils.latinToExtendedArabicDigit(registerNo);

        currentRecord.setSubfieldData(Tags.HOL_INFO_SERVICE_POLICY, 'a', servicePolicy);
        currentRecord.setSubfieldRangeData(
            Tags.HOL_ACQUISITION_STATUS, 'a', acquisitionStatus, 1, 1);
        currentRecord.setSubfieldData(
            Tags.HOL_LOC_CALL_NO, 'b', registerBean.getLocationItem().getCode());
        currentRecord.setSubfieldData(Tags.HOL_LOC_CALL_NO, 'm', registerNo);

        // regsList.getIndex() started of 1
        final int index = regList.getIndex() - 1;

        String volume = registerBean.getVolume();
        if (registerBean.isHasCounterVolume()) {
          volume = String.valueOf(Integer.valueOf(volume) + index);
        }
        volume =
            (isLeftToRight)
                ? StringUtils.extendedArabicToLatinDigit(volume)
                : StringUtils.latinToExtendedArabicDigit(volume);
        currentRecord.setSubfieldData(Tags.HOL_COPY_VOL_INFO, 'a', volume);

        String copy = registerBean.getCopy();
        if (registerBean.isHasCounterCopy()) {
          copy = String.valueOf(Integer.valueOf(copy) + index);
        }
        copy =
            (isLeftToRight)
                ? StringUtils.extendedArabicToLatinDigit(copy)
                : StringUtils.latinToExtendedArabicDigit(copy);
        currentRecord.setSubfieldData(Tags.HOL_COPY_VOL_INFO, 'b', copy);

        String address = registerBean.getAddress();
        if (registerBean.isHasCounterAddress()) {
          address = String.valueOf(Integer.valueOf(address) + index);
        }
        address =
            (isLeftToRight)
                ? StringUtils.extendedArabicToLatinDigit(address)
                : StringUtils.latinToExtendedArabicDigit(address);
        currentRecord.setSubfieldData(Tags.HOL_COPY_VOL_INFO, 'c', address);

        String section = registerBean.getSection();
        if (registerBean.isHasCounterSection()) {
          section = String.valueOf(Integer.valueOf(section) + index);
        }
        section =
            (isLeftToRight)
                ? StringUtils.extendedArabicToLatinDigit(section)
                : StringUtils.latinToExtendedArabicDigit(section);
        currentRecord.setSubfieldData(Tags.HOL_COPY_VOL_INFO, 'd', section);

        String date = registerBean.getDate();
        if (StringUtils.isNotEmpty(date)) {
          date =
              (isLeftToRight)
                  ? StringUtils.extendedArabicToLatinDigit(date)
                  : StringUtils.latinToExtendedArabicDigit(date);
          currentRecord.setSubfieldData(Tags.HOL_COPY_VOL_INFO, 'e', date);
        }

        String print = registerBean.getPrint();
        if (StringUtils.isNotEmpty(print)) {
          print =
              (isLeftToRight)
                  ? StringUtils.extendedArabicToLatinDigit(print)
                  : StringUtils.latinToExtendedArabicDigit(print);
          currentRecord.setSubfieldData(Tags.HOL_LOC_CALL_NO, '9', print);
        }

        String ref = registerBean.isReferences() ? "1" : "0";
        ref =
            (isLeftToRight)
                ? StringUtils.extendedArabicToLatinDigit(ref)
                : StringUtils.latinToExtendedArabicDigit(ref);
        currentRecord.setSubfieldData(Tags.HOL_COPY_VOL_INFO, 'r', ref);

        DataEntryModel dataEntryModel = registerBean.getDataEntryModel();
        try {
          StorageWebUtils.getInstance()
              .tryToPost(
                  dataEntryModel,
                  currentRecord.getBibliographicRecord(),
                  currentRecord,
                  registerNo,
                  registerBean.getLocationItem(),
                  JsfUtils.getInstance().getLocale());
        } catch (DuplicateRegisterRecordException e) {
          JsfUtils.getInstance().addFormattedError(e.getMessage());
          regList.next();
        }
        dataEntryModel.cancel();
        StorageWebUtils.getInstance()
            .releaseRecordLock(currentRecord.getClass(), currentRecord.getId(), true);
        dataEntryModel =
            StorageWebUtils.getInstance()
                .createDataEntryModel(
                    Register.class, null, 0, currentRecord.getBibliographicRecord(), true);
        registerBean.setDataEntryModel(dataEntryModel);
      }
    } catch (Exception e) {

    }
  }