Пример #1
0
  private void loadData() throws IllegalArgumentException, Exception {
    bcClientType.removeAllItems();
    bcClientType.addAll(clientTypeService.getAll(context.getUser().getActiveOrganization()));

    clientTypeField.setContainerDataSource(bcClientType);

    bcClientGroup.removeAllItems();
    bcClientGroup.addAll(clientGroupService.getAll(context.getUser().getActiveOrganization()));

    clientGroupField.setContainerDataSource(bcClientGroup);
  }
Пример #2
0
  public Client parse() {
    if (row.getCell(CODE) == null) {
      try {
        client.setCode(sequenceService.setNextSequence(Sequence.CODE.CLIENT.name()));
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else client.setCode(row.getCell(CODE).getStringCellValue());

    if (row.getCell(NAME) != null) client.setName(row.getCell(NAME).getStringCellValue());

    if (row.getCell(DESCRIPTION) != null)
      client.setDescription(row.getCell(DESCRIPTION).getStringCellValue());

    if (row.getCell(PHONE) != null) {
      row.getCell(PHONE).setCellType(Cell.CELL_TYPE_STRING);
      client.setPhone(row.getCell(PHONE).getStringCellValue());
    }

    if (row.getCell(FAX) != null) {
      row.getCell(FAX).setCellType(Cell.CELL_TYPE_STRING);
      client.setFax(row.getCell(FAX).getStringCellValue());
    }

    if (row.getCell(MOBILE) != null) {
      row.getCell(MOBILE).setCellType(Cell.CELL_TYPE_STRING);
      client.setMobile(row.getCell(MOBILE).getStringCellValue());
    }

    if (row.getCell(EMAIL) != null) client.setEmail(row.getCell(EMAIL).getStringCellValue());

    if (row.getCell(ADDRESS) != null) {
      Address address = null;
      try {
        address = addressService.getByStreet(row.getCell(ADDRESS).getStringCellValue());
      } catch (Exception e) {
        address = new Address();
        address.setStreet(row.getCell(ADDRESS).getStringCellValue());
      }

      client.setClientAddress(address);
    }

    if (row.getCell(VAT) != null) client.setVat(row.getCell(VAT).getStringCellValue());

    if (row.getCell(TYPE) != null) {
      ClientType clientType = null;
      try {
        clientType = clientTypeService.getByCode(row.getCell(TYPE).getStringCellValue());
      } catch (Exception e) {
        clientType = new ClientType();
        clientType.setCode(row.getCell(TYPE).getStringCellValue());
        clientType.setDescription(row.getCell(TYPE).getStringCellValue());
      }

      client.setClientType(clientType);
    }

    if (row.getCell(GROUP) != null) {
      ClientGroup clientGroup = null;
      try {
        clientGroup = clientGroupService.getByName(row.getCell(GROUP).getStringCellValue());
      } catch (Exception e) {
        clientGroup = new ClientGroup();
        clientGroup.setName(row.getCell(GROUP).getStringCellValue());
        clientGroup.setDescription(row.getCell(GROUP).getStringCellValue());
      }

      client.setClientGroup(clientGroup);
    }

    if (row.getCell(COMMENT) != null) client.setComment(row.getCell(COMMENT).getStringCellValue());

    if (row.getCell(ACTIVE) != null) {
      if (row.getCell(ACTIVE).getStringCellValue().equals("1")) client.setActive(true);
      else client.setActive(false);
    }

    return client;
  }