public void insertAction(ActionEvent event) {
   try {
     String fromIndex = StringUtils.extendedArabicToLatinDigit(registerBean.getRegNoFrom());
     String toIndex = StringUtils.extendedArabicToLatinDigit(registerBean.getRegNoUntil());
     RegisterContainer registerContainer = RegisterNumberParser.parse(fromIndex, toIndex);
     registerBean.setRegList((StorageContainer.NodeIterator) registerContainer.iterator());
     JsfUtils.callFunctionScript("disableAllElements", "");
   } catch (NumberFormatException e) {
     JsfUtils.getInstance().addError("invalidNumberFormatMsg");
     JsfUtils.callFunctionScript("enableAllElements()", "");
   } catch (IllegalArgumentException e) {
     JsfUtils.getInstance().addError("regnoFrom_is_greater_than_regnoTo_message");
     JsfUtils.callFunctionScript("enableAllElements()", "");
   } catch (IllegalStateException e) {
     JsfUtils.getInstance().addError("regno_is_too_long_message");
     JsfUtils.callFunctionScript("enableAllElements()", "");
   }
 }
Ejemplo n.º 2
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();
    //		  }

  }
  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) {

    }
  }