Package beans.directory.checkuptype.entity

Examples of beans.directory.checkuptype.entity.CheckupType


        Laboratory laboratory = findEntity(Laboratory.class, laboratoryID);
        //Iterator list = findEntityList("LaborType", "laboratory", laboratory).iterator();
        Iterator<CheckupType> list = laboratory.getCheckupTypes().iterator();
        Set<Integer> res = new HashSet<Integer>();
        while(list.hasNext()) {
            CheckupType ct = list.next();
            res.add(ct.getId());
        }
        return res;
    }
View Full Code Here


    private void onRemoveIntelWriterType(DirectoryEntity entity) throws ClipsServerException {
        int iwtID = ((IntelWriterType) entity).getId();
        List entityList = findEntityList(CheckupType.class);
        for (int i = 0; i < entityList.size(); i++) {
            CheckupType checkupType = (CheckupType) entityList.get(i);
            String metadata = checkupType.getMetadata();
            try {
                Document xml = Converter.stringToXml(metadata);

                List l = xml.getRootElement().getChildren();
                for (int j = 0; j < l.size(); j++) {
                    Element element = (Element) l.get(j);
                    if (element.getName().equals("field")) {
                        String id = element.getChildTextTrim("id");
                        if (id != null) {
                            try {
                                int intID = Integer.parseInt(id);
                                if (iwtID == intID) {
                                    throw new EDataIntegrity("Этот тип уже используется в анализе (" + checkupType.getTitle() + ")");
                                }
                            } catch (NumberFormatException ex) {
                                throw new ClipsServerException("Некорректная xml (CheckupType " + checkupType.getTitle() + ")", ex);
                            }
                        }
                    }
                }


            } catch (JDOMException ex) {
                throw new ClipsServerException("Некорректная xml (CheckupType " + checkupType.getTitle() + ")", ex);
            }
        }
    }
View Full Code Here

        return UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY;
    }

    @Override
    protected void set(CheckupType entity, CheckupTypeDetails details) {
        CheckupType checkupType = entity;
        CheckupTypeDetails d = details;
        checkupType.setTitle(d.title);
        //checkupType.setDirty(details.dirty);
        checkupType.setMetadata(d.metadata);
        checkupType.setDescription(d.description);
        checkupType.setIsanalyse(d.isAnalyse);
        checkupType.setTrash(d.hidden);
    }
View Full Code Here

        check(details);
    }

    @Override
    protected void onRemove(CheckupType entity) throws ClipsServerException {
        CheckupType checkupType = entity;
        Field f[] = { new Field("checkupType", checkupType) };
        //проверяем, если ли связанные услуги
        List serviceList = findEntityList(Service.class, f);
        if(serviceList.size() > 0) {
            String s = "";
            for (int i = 0; i < serviceList.size(); i++) {
                Service service = (Service)serviceList.get(i);
                s += "\n" + service.getCodeAndTitle();
            }
            throw new EDataIntegrity("Удаление невозможно, с данным анализом связаны следующие услуги" + s);
        }
        //проверяем, есть ли связанные осмотры
        Field f2[] { new Field("checkupType", checkupType) };
        if(getEntityCount(Checkup.class, f2) > 0) {
            throw new EMoveToTrash("Существуют анализы и осмотры данного типа, удаление невозможно");
        }
       
        //удаляем связи с лабораториями
        try {
            String sql = "Select a FROM " + Laboratory.class.getSimpleName() + " a" +
                    ", IN (a.checkupTypes) as ch WHERE ch.id = :checkupType";
            Query query = manager.createQuery(sql);
            query.setParameter("checkupType", checkupType.getId());
            Iterator i = query.getResultList().iterator();
            while(i.hasNext()) {
                Laboratory lab = (Laboratory) i.next();
                lab.getCheckupTypes().remove(checkupType);
                manager.merge(lab);
View Full Code Here

TOP

Related Classes of beans.directory.checkuptype.entity.CheckupType

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.