Package org.xBaseJ.micro

Examples of org.xBaseJ.micro.DBF


* @author finder
*/
public class DBMesImport {
  public void dbImport(File dbFile){
    try {
      DBF dbf = new DBF(dbFile.getAbsolutePath(), "cp866");
      System.out.println("DBMesImport: parse file '" + dbFile.getName());
    }
    catch (xBaseJException ex) {
      Logger.getLogger(DBMesImport.class.getName()).log(Level.SEVERE, null, ex);
    }
View Full Code Here


    @Override
    final public void updateImpl() throws ClipsException {
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<String, Field> fields = new HashMap<String, Field>();
        try {
            fields.put("ID", dbf.getField(idField));
            fields.put("NAME", dbf.getField(titleField));
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        //мап существующих итемов по внешнему ключу
        //потом будет списком на удаление
        HashMap<String,DIRECTORYITEM> presentItems = new HashMap<String, DIRECTORYITEM>();
        //мап существующих итемов для изменения Тайтла
        HashMap<DIRECTORYITEM,String> changeList = new HashMap<DIRECTORYITEM, String>();
        //список итемов для добавления
        ArrayList<DIRECTORYITEM> addList = new ArrayList<DIRECTORYITEM>();
        ROList<DIRECTORYITEM> itemsList = dir.getItemsList();
        for (int i = 0; i < itemsList.size(); i++) {
            DIRECTORYITEM item = itemsList.get(i);
            if (item.getID() != 0 && !item.getExtKey().trim().isEmpty()) {
                presentItems.put(item.getExtKey().trim(), item);
            }
        }

        int recordCount = dbf.getRecordCount();
        for (int c = 0; c < recordCount; c++) {
            try {
                dbf.read();
                String id = fields.get("ID").get().trim();
                String name = fields.get("NAME").get().trim();
                System.out.println(id + "  " + name);
                DIRECTORYITEM pItem = presentItems.get(id);
                if (pItem != null) {
                    if (!pItem.getTitle().equals(name) || !pItem.isVisible()) {
                        //либо разпассивировать либо сменить тайтл
                        changeList.put(pItem, name);
                    }
                    presentItems.remove(id);
                } else {
                    //Создать новый
                    DirectoryItemDetails details = new DirectoryItemDetails();
                    details.title = name;
                    details.external_key = id;
                    DIRECTORYITEM newItem = (DIRECTORYITEM) dir.initNewItem(name);
                    newItem.setExtKey(id);
                    addList.add(newItem);
                }
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
            }
        }
        closeDBF(dbf);
        //Удаление (а может пассивация решает бин)
        for (DIRECTORYITEM item : presentItems.values()) {
View Full Code Here

        }

        ClipsConfig cfg = ClipsConfig.getInstance();

        File file = new File(cfg.getLastDBFImportPath(), getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
                fields.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        int recordCount = dbf.getRecordCount();

        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                String ogrn = fields.get(Col.C_OGRN).get().trim();
                String tfLpuCode = fields.get(Col.MCOD).get().trim();
                if (ogrn.equals(lpuOGRN) && tfLpuCode.equals(lpuCode)) {
                    String collCode = fields.get(Col.PCOD).get().trim();
                    DirectoryCollaboratorItem coll = collMap.get(collCode);
                    if (coll != null) {
                        CollaboratorLocal collab = new CollaboratorLocal(coll.getID(), null);//NULL AL
                        Date begin;
                        String begStr = fields.get(Col.DATE_B).get().trim();
                        if (begStr.isEmpty()) {
                            begin = null;
                        }
                        else {
                            begin = ((DateField)fields.get(Col.DATE_B)).getCalendar().getTime();
                        }
                        Date end;
                        String endStr = fields.get(Col.DATE_E).get().trim();
                        if (endStr.isEmpty()) {
                            end = null;
                        }
                        else {
                            end = ((DateField)fields.get(Col.DATE_E)).getCalendar().getTime();
                        }
                        Date cur = TimeLocal.getCurrentTime().getTime();
                        if ((begin != null && begin.before(cur))
                                && (end != null && end.after(cur) || end == null || Comparator.dataEqual(end, nullDate))) {
                            collab.setDlo(true);
                            collab.save1();
                        }
                        else {
                            if (collab.isDlo()) {
                                collab.setDlo(false);
                                collab.save1();
                            }
                        }
                       
                    }
                }
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
        }
    }
View Full Code Here

        dirWeightUnit = DirectoryLocator.getDirectory(DirectoryDrugWeightUnit.class);
        dirFarmGroup = DirectoryLocator.getDirectory(DirectoryDrugFarmGroup.class);
        dirSection = DirectoryLocator.getDirectory(DirectoryDloDrugSection.class);

        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
                fields.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        GregorianCalendar gc1 = new GregorianCalendar();
        int recordCount = dbf.getRecordCount();
        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                if ((i%1000) == 0) {
                    System.out.println("Обновление пациентов : " +  i/((float)recordCount)*100 + "% (" + i + ") запись");
                    GregorianCalendar gc2 = new GregorianCalendar();
                    long mc = gc2.getTimeInMillis() - gc1.getTimeInMillis();
                    System.out.println("Work time: " + mc + " ms");
                }
                if (dbf.deleted()) {
                    continue;
                }

                DloDrugListDetails det = new DloDrugListDetails();

                det.code = Integer.parseInt(fields.get(Col.NOMK_LS).get().trim());
                det.title = fields.get(Col.NAME_MED).get().trim();
                det.tradeNameId = dirTradeName.getItemFromExtKey(fields.get(Col.C_TRN).get().trim()).getID();
                det.mnnId = dirMNN.getItemFromExtKey(fields.get(Col.C_MNN).get().trim()).getID();
                det.dosageFormId = dirDosageForm.getItemFromExtKey(fields.get(Col.C_LF).get().trim()).getID();
                det.dosage = fields.get(Col.D_LS).get().trim();
                det.dosageUnitId = dirDosageUnit.getItemFromExtKey(fields.get(Col.C_DLS).get().trim()).getID();
                det.dosageQuantity = Integer.parseInt(fields.get(Col.N_DOZA).get().trim());
                det.volume = Double.parseDouble(fields.get(Col.V_LF).get().trim());
                det.volumeUnitId = dirVolumeUnit.getItemFromExtKey(fields.get(Col.C_VLF).get().trim()).getID();
                det.weight = Double.parseDouble(fields.get(Col.M_LF).get().trim());
                det.weightUnitId = dirWeightUnit.getItemFromExtKey(fields.get(Col.C_MLF).get().trim()).getID();
                det.packNumber = Integer.parseInt(fields.get(Col.N_FV).get().trim());
                det.producer = fields.get(Col.NAME_FCT).get().trim();
                det.producerCountry = fields.get(Col.NAME_CNF).get().trim();
                det.packer = fields.get(Col.NAME_PCK).get().trim();
                det.packerCountry = fields.get(Col.NAME_CNP).get().trim();
                det.completeness = fields.get(Col.COMPL).get().trim();
                det.farmGroupId = dirFarmGroup.getItemFromExtKey(fields.get(Col.C_FARG).get().trim()).getID();

                int flag = Integer.parseInt(fields.get(Col.FLAG_KEK).get().trim());
                if (flag == 0) {
                    det.kekRequired = false;
                }
                else {
                    det.kekRequired = true;
                }

                flag = Integer.parseInt(fields.get(Col.FLAG1).get().trim());
                if (flag == 0) {
                    det.vital = false;
                }
                else {
                    det.vital = true;
                }

                flag = Integer.parseInt(fields.get(Col.FLAG2).get().trim());
                if (flag == 0) {
                    det.forbidden = false;
                }
                else {
                    det.forbidden = true;
                }

                det.dateIn = null;
                try {
                    Calendar nsuBegin = ((DateField)fields.get(Col.DATE_B)).getCalendar();
                    if (Comparator.dataEqual(nullDate, nsuBegin.getTime())) {
                        det.dateIn = null;
                    }
                    else {
                        det.dateIn = nsuBegin.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата вкючения в перечень некорректна " + dbf.getName() + " code=(" + det.code + ")");
                    out.println("Предупреждение : Дата включения в перечень некорректна " + dbf.getName() + " code=(" + det.code + ")");
                }

                det.dateOut = null;
                try {
                    Calendar nsuBegin = ((DateField)fields.get(Col.DATE_E)).getCalendar();
                    if (Comparator.dataEqual(nullDate, nsuBegin.getTime())) {
                        det.dateOut = null;
                    }
                    else {
                        det.dateOut = nsuBegin.getTime();
                    }
                } catch (NumberFormatException ex) {
                    System.out.println("Предупреждение : Дата исключения из перечня некорректна " + dbf.getName() + " code=(" + det.code + ")");
                    out.println("Предупреждение : Дата исключения из перечня некорректна " + dbf.getName() + " code=(" + det.code + ")");
                }

                det.msg = fields.get(Col.MSG_TEXT).get().trim();
                try {
                    det.sectionId = dirSection.getItemByCode(Integer.parseInt(fields.get(Col.C_RLP).get().trim())).getID();
                } catch (ClipsException ex) {
                    det.sectionId = 0;
                    System.out.println("Предупреждение: Не найден раздел перечня " + dbf.getName() + " code=(" + det.code + ")");
                    out.println("Предупреждение: Не найден раздел перечня " + dbf.getName() + " code=(" + det.code + ")");
                }

                DirectoryDrugListItem item = new DirectoryDrugListItem(det);
                drugList.getItems().append(item);
            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
        }
    }
View Full Code Here

        dirCollab = DirectoryLocator.getDirectory(DirectoryCollaborator.class);
        collabList = null;
        clientSearchLocal = new ClientSearchLocal(am);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<Col, Field> fields = new HashMap<Col, Field>();
        try {
            for (int i = 0; i < Col.values().length; i++) {
                Col col = Col.values()[i];
                fields.put(col, dbf.getField(col.toString()));
            }
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }
        int recordCount = dbf.getRecordCount();

        DirectorySurname dirSurname = DirectoryLocator.getDirectory(DirectorySurname.class);
        DirectoryName dirName = DirectoryLocator.getDirectory(DirectoryName.class);
        DirectoryPathron dirPathron = DirectoryLocator.getDirectory(DirectoryPathron.class);
        DirectorySpeciality dirSpec = DirectoryLocator.getDirectory(DirectorySpeciality.class);
        DirectoryReceptionType dirRecType = DirectoryLocator.getDirectory(DirectoryReceptionType.class);
        DirectoryDvr dirDvr = DirectoryLocator.getDirectory(DirectoryDvr.class);
        DirectoryMedicalAidType dirVmu = DirectoryLocator.getDirectory(DirectoryMedicalAidType.class);
        colDataList = new ArrayList<CollabData>();
        colClientMap = new HashMap<ColDataKey, ArrayList<ClientLocal>>();
        for (int i = 0; i < recordCount; i++) {
            try {
                dbf.read();
                if (dbf.deleted()) {
                    continue;
                }
                if (fields.get(Col.FAMILY).get().trim().isEmpty()) {
                    continue;
                }
                String extKey = fields.get(Col.ID).get().trim();
                DirectorySurnameItem surename = dirSurname.getItemFromTitle(fields.get(Col.FAMILY).get().trim());
                if (surename == null) {
                    DirectoryItemDetails d = new DirectoryItemDetails(fields.get(Col.FAMILY).get().trim());
                    surename = new DirectorySurnameItem(d);
                    dirSurname.getItems().append(surename);
                }
                int surnameID = surename.getID();
                DirectoryNameItem name = dirName.getItemFromTitle(fields.get(Col.NAME).get().trim());
                if (name == null) {
                    DirectoryItemDetails d = new DirectoryItemDetails(fields.get(Col.NAME).get().trim());
                    name = new DirectoryNameItem(d);
                    dirName.getItems().append(name);
                }
                int nameID = name.getID();
                //Финт ушами - исправление отчества
                String father = fields.get(Col.FATHER).get().trim();
                if (father.equals("Тимирьянович")) {
                    father = "Тимерзянович";
                }
                DirectoryPathronItem pathron = dirPathron.getItemFromTitle(father);
                if (pathron == null) {
                    DirectoryItemDetails d = new DirectoryItemDetails(father);
                    pathron = new DirectoryPathronItem(d);
                    dirPathron.getItems().append(pathron);
                }
                int pathronID = pathron.getID();
                int specID = dirSpec.getItemFromExtKey(fields.get(Col.KOD_SPEC).get().trim()).getID();
                DirectoryReceptionTypeItem recType = dirRecType.getItemFromExtKey(fields.get(Col.KOD_PRIEM).get().trim());
                if (recType == null) {
                    recType = dirRecType.getItemFromExtKey("600");
                }
                int receptionTypeID = recType.getID();
                DirectoryDvrItem dvr = dirDvr.getItemFromExtKey(fields.get(Col.DOLV).get().trim());
                if (dvr == null) {
                    dvr = dirDvr.getItemFromID(0);
                }
                int dvrID = dvr.getID();
                DirectoryMedicalAidTypeItem vmu = dirVmu.getItemFromExtKey(fields.get(Col.VMU).get().trim());
                if (vmu == null) {
                    vmu = dirVmu.getItemFromID(0);
                }
                int vmuID = vmu.getID();
                String snils = fields.get(Col.SNILS).get().trim();

                CollabData cd = new CollabData(extKey, surnameID, nameID, pathronID, specID, receptionTypeID, dvrID, vmuID);
                ColDataKey key = new ColDataKey(surnameID, nameID, pathronID);
                colClientMap.put(key, findClient(surename.getTitle(), name.getTitle(), pathron.getTitle(), snils));
                colDataList.add(cd);

            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            } catch (NumberFormatException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " (строка " + i + ")", ex);
            }
        }
        changeData();
    }
View Full Code Here

    @Override
    public void updateImpl() throws ClipsException {
        dir = DirectoryLocator.getDirectory(DirectoryKladrType.class);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<String, Field> fields = new HashMap<String, Field>();
        try {
            fields.put("ID", dbf.getField("ID"));
            fields.put("CUTNAME", dbf.getField("CUTNAME"));
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        int recordCount = dbf.getRecordCount();
        for (int c = 0; c < recordCount; c++) {
            try {
                dbf.read();
                String extKey = fields.get("ID").get().trim();
                String cutName = fields.get("CUTNAME").get().trim();
                ArrayList<DirectoryKladrTypeItem> items = getItemsByShortTitle(cutName);
                if (items.size() != 0) {
                    for (DirectoryKladrTypeItem item : items) {
                        item.setExtKey(extKey);
                    }
                }

            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " строка + " + c, ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " строка + " + c, ex);
            }
        }
        closeDBF(dbf);

    }
View Full Code Here

        HashSet<VisitPrice> visitPriceSet = new HashSet<VisitPrice>();

        ClipsConfig cfg = ClipsConfig.getInstance();
        {
            File file = new File(cfg.getLastDBFImportPath(), S_VISIT);
            DBF dbfVisit = createDBF(file);
            HashMap<ColVisit, Field> fieldsVisit = new HashMap<ColVisit, Field>();
            try {
                for (int i = 0; i < ColVisit.values().length; i++) {
                    ColVisit col = ColVisit.values()[i];
                    fieldsVisit.put(col, dbfVisit.getField(col.toString()));
                }
            } catch (xBaseJException ex) {
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfVisit.getName(), ex);
            }

            int recordCount = dbfVisit.getRecordCount();
            for (int c = 0; c < recordCount; c++) {
                try {
                    dbfVisit.read();
                    String id = fieldsVisit.get(ColVisit.ID).get().trim();
                    String price = fieldsVisit.get(ColVisit.PRICE).get().trim();
                    visitPriceSet.add(new VisitPrice(id, price));
                    System.out.println(id + " " + price);
                } catch (IOException ex) {
                    closeDBF(dbfVisit);
                    throw new ClipsException("Ошибка при чтении данных из файла " + dbfVisit.getName(), ex);
                } catch (xBaseJException ex) {
                    closeDBF(dbfVisit);
                    throw new ClipsException("Ошибка при чтении данных из файла " + dbfVisit.getName(), ex);
                }
            }
            closeDBF(dbfVisit);
        }

        {
            File file = new File(cfg.getLastDBFImportPath(), S_UET);
            DBF dbfUET = createDBF(file);
            HashMap<ColUet, Field> fieldsUet = new HashMap<ColUet, Field>();
            try {
                for (int i = 0; i < ColVisit.values().length; i++) {
                    ColUet col = ColUet.values()[i];
                    fieldsUet.put(col, dbfUET.getField(col.toString()));
                }
            } catch (xBaseJException ex) {
                throw new ClipsException("Ошибка при чтении данных из файла " + dbfUET.getName(), ex);
            }

            int recordCount = dbfUET.getRecordCount();
            for (int c = 0; c < recordCount; c++) {
                try {
                    dbfUET.read();
                    String id = fieldsUet.get(ColUet.LEVELMES).get().trim();
                    String price = fieldsUet.get(ColUet.PRICE).get().trim();
                    VisitPrice vp = new VisitPrice(id + "29000", price);
                    if (visitPriceSet.contains(vp)) {
                        visitPriceSet.remove(vp);
                    }
                    visitPriceSet.add(vp);
                    System.out.println(vp.getId() + " " + vp.getPrice());
                    vp = new VisitPrice(id + "29824", price);
                    if (visitPriceSet.contains(vp)) {
                        visitPriceSet.remove(vp);
                    }
                    visitPriceSet.add(vp);
                    System.out.println(vp.getId() + " " + vp.getPrice());
                    vp = new VisitPrice(id + "29825", price);
                    if (visitPriceSet.contains(vp)) {
                        visitPriceSet.remove(vp);
                    }
                    visitPriceSet.add(vp);
                    System.out.println(vp.getId() + " " + vp.getPrice());
                } catch (IOException ex) {
                    closeDBF(dbfUET);
                    throw new ClipsException("Ошибка при чтении данных из файла " + dbfUET.getName(), ex);
                } catch (xBaseJException ex) {
                    closeDBF(dbfUET);
                    throw new ClipsException("Ошибка при чтении данных из файла " + dbfUET.getName(), ex);
                }
            }
            closeDBF(dbfUET);
        }
View Full Code Here

    @Override
    public void updateImpl() throws ClipsException {
        dirMKB = DirectoryLocator.getDirectory(DirectoryMKB10.class);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<String, Field> fields = new HashMap<String, Field>();
        try {
            //fields.put("PRIZNAK", dbf.getField("PRIZNAK"));
            fields.put("CODE", dbf.getField("CODE"));
            fields.put("NAME", dbf.getField("NAME"));
            //fields.put("SHIFT", dbf.getField("SHIFT"));
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        int recordCount = dbf.getRecordCount();
        for (int c = 0; c < recordCount; c++) {
            try {
                if ((c%500) == 0) {
                    System.out.println("Обновление МКБ выполнено " + (c+1)/((float)recordCount)*100 + "%");
                    out.println("Обновление МКБ выполнено " + (c+1)/((float)recordCount)*100 + "%");
                }
                dbf.read();
                //String priznak = fields.get("PRIZNAK").get().trim();
                String kod = fields.get("CODE").get().trim();
                String title = fields.get("NAME").get().trim();
                //String shortTitle = fields.get("SHIFT").get().trim();
                /*if (priznak.equals("1")
                        || title.isEmpty() && shortTitle.isEmpty()) {
                    continue;
                }*/
                if (title.isEmpty()) {
                    continue;
                }

                DirectoryMKB10Item item = dirMKB.getItemByCode(kod);
                if (item == null) {
                    DirectoryMKB10Item parent = getParent(kod);
                    Mkb10Details d = new Mkb10Details();
                    d.code = kod;
                    d.title = title;
                    //d.shortTitle = shortTitle;
                    d.parentItem = parent.getID();
                    item = new DirectoryMKB10Item(d);
                    parent.getItems().append(item);
                    System.out.println("Новый МКБ итем : " + item);
                }
                if (!item.getTitle().equals(title)) {
                    //System.out.println("МКБ итем - другое название : " + title);
                    //item.setTitle(title);
                }
                /*if (!item.getShortTitle().equals(shortTitle)) {
                    item.setShortTitle(shortTitle);
                }*/

            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " строка + " + c, ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName() + " строка + " + c, ex);
            } catch (ParseException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при парсинге кода мкб. Файл " + dbf.getName() + " строка + " + c, ex);
            }
        }
        closeDBF(dbf);

    }
View Full Code Here

        dirReqType = DirectoryLocator.getDirectory(DirectoryReqType.class);
        dirVisitType = DirectoryLocator.getDirectory(DirectoryVisitType.class);
        dirServiceClass = DirectoryLocator.getDirectory(DirectoryServiceClass.class);
        ClipsConfig cfg = ClipsConfig.getInstance();
        File file = new File(cfg.getLastDBFImportPath(),getFilename());
        DBF dbf = createDBF(file);
        HashMap<String, Field> fields = new HashMap<String, Field>();
        try {
            fields.put("ID", dbf.getField("ID"));
            fields.put("REQTYPE", dbf.getField("REQTYPE"));
            fields.put("VISITNAME", dbf.getField("VISITNAME"));
            fields.put("VISITTYPE", dbf.getField("VISITTYPE"));
        } catch (xBaseJException ex) {
            throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
        }

        //1 этап считывание данных из DBF и сохранение в мап чтобы исключить повторные
        //мап по коду
        HashMap<String, ServiceData> codeMap = new HashMap<String, ServiceData>();
        int recordCount = dbf.getRecordCount();
        for (int c = 0; c < recordCount; c++) {
            try {
                dbf.read();
                String id = fields.get("ID").get().trim();
                if (!Pattern.matches("[0-9]{6}",id)) {
                    throw new ClipsException("Неправильный код посещения : " + id);
                }
                String shortID = id.substring(3, 6);
                ServiceData d = new ServiceData();
                d.reqType = fields.get("REQTYPE").get().trim();
                d.name = fields.get("VISITNAME").get().trim();
                d.visitType = fields.get("VISITTYPE").get().trim();
                codeMap.put(shortID, d);

            } catch (IOException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
            } catch (xBaseJException ex) {
                closeDBF(dbf);
                throw new ClipsException("Ошибка при чтении данных из файла " + dbf.getName(), ex);
            }
        }
        closeDBF(dbf);

View Full Code Here

            File dir = new File(cfg.getRegisterExportPath(), "SEND");
            dir.mkdir();
            dir = new File(dir, dloRegDir);
            dir.mkdir();
            File dbfFile = new File(dir, "REG_PIN.DBF");
            regPin = new DBF(dbfFile.getAbsolutePath(), true, "cp866");
        }
        regPin.startTop();
    }
View Full Code Here

TOP

Related Classes of org.xBaseJ.micro.DBF

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.