Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

In this page you can find the example usage for java.util Hashtable get.

Prototype

@SuppressWarnings("unchecked")
public synchronized V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:controller.controller.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  w  w  w. j  a  v  a 2s . c  o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    HttpSession session = request.getSession();
    try (PrintWriter out = response.getWriter()) {
        /* TODO output your page here. You may use following sample code. */
        String action = request.getParameter("action");
        String type = request.getParameter("type");
        System.out.println(action);
        if (action.equals("getproduct")) {
            System.out.println(type);
            DAO dao = new DAO();
            ArrayList<pro> product = dao.getProduct(type);
            session.setAttribute("product", product);
            dispatcher(request, response, "tablet.jsp");
        }

        if (action.equals("productDetail")) {
            int id = Integer.parseInt(request.getParameter("id"));
            DAO detail = new DAO();
            pro productDetail = detail.productDetail(id);
            session.setAttribute("productdetail", productDetail);
            dispatcher(request, response, "view.jsp");
        }
        if (action.equals("AddtoCart")) {
            System.out.println(action);
            shoppingCart cart = (shoppingCart) session.getAttribute("cart");

            if (cart == null) {
                System.out.println("cart: " + null);
                cart = new shoppingCart();
            }

            System.out.println("product " + session.getAttribute("productdetail"));

            pro temp = (pro) session.getAttribute("productdetail");
            int qu = temp.getQuantity();
            System.out.println("qu " + qu);
            if (qu > 0) {
                --qu;
                System.out.println("qu " + qu);
                temp.setQuantity(qu);
                //int quantity = Integer.parseInt(request.getParameter("quantity"));

                cart.addProduct(temp);
                System.out.println("cart " + cart.getProducts().size());
            }
            session.setAttribute("cart", cart);

        }
        if (action.equals("checkout")) {
            System.out.println(action);
            shoppingCart cart = (shoppingCart) session.getAttribute("cart");
            if (cart == null) {
                cart = new shoppingCart();
            }
            session.setAttribute("cart", cart);
            dispatcher(request, response, "checkout.jsp");
        }

        if (action.equals("order")) {
            shoppingCart cart = (shoppingCart) session.getAttribute("cart");
            String accid = (String) session.getAttribute("login");
            DAO dao = new DAO();
            dao.order(cart, accid);
            session.removeAttribute("cart");
            response.sendRedirect("index.jsp");

        }
        if (action.equals("upload")) {

            String dirNames = "D:\\Task\\IU\\Web Application Development\\New\\Final project\\ECommerceProject";

            String user = (String) session.getAttribute("login");

            String fileName = null;
            boolean isMultiPArt = ServletFileUpload.isMultipartContent(request);

            if (isMultiPArt) {
                System.out.println(1);
                FileItemFactory factory = new DiskFileItemFactory();
                ServletFileUpload upload = new ServletFileUpload(factory);
                List items = null;
                try {
                    items = upload.parseRequest(request);
                } catch (FileUploadException e) {
                    e.printStackTrace();
                }
                Iterator iter = items.iterator();
                Hashtable params = new Hashtable();

                File theDir = new File(dirNames + File.separator + user);

                // if the directory does not exist, create it
                if (!theDir.exists()) {
                    System.out.println("creating directory: " + user);
                    boolean result = false;

                    try {
                        theDir.mkdir();
                        result = true;
                    } catch (SecurityException se) {
                        //handle it
                    }
                    if (result) {
                        System.out.println("DIR created");
                    }
                }
                String[] url = new String[5];
                int cnt = 0;
                while (iter.hasNext()) {
                    FileItem item = (FileItem) iter.next();
                    if (item.isFormField()) {
                        params.put(item.getFieldName(), item.getString());
                    } else {
                        try {
                            String itemName = item.getName();
                            fileName = itemName.substring(itemName.lastIndexOf("\\") + 1);
                            System.out.println("path: " + fileName);
                            String realPath = dirNames + File.separator + user + File.separator + fileName;
                            System.out.println("realPath: " + realPath);
                            File savedFile = new File(realPath);
                            item.write(savedFile);
                            url[cnt] = "./database" + File.separator + user + File.separator + fileName;
                            ++cnt;
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }

                String name = (String) params.get("name");
                String price = (String) params.get("price");
                String quantity = (String) params.get("quantity");
                String typepr = (String) params.get("type");

                System.out.println(name + " " + price + " " + quantity + " " + typepr);

                DAO uploadReal = new DAO();
                uploadReal.inserPro(name, price, quantity, typepr, url[0]);
                //                        newUser = new User();
                //                        newUser.setEmail(Email);
                out.print(url[0]);
                String temp = ".\\User" + File.separator + user + File.separator + fileName;
                System.out.println("Temp " + temp);

                //Connector.editUser(myProfile.getEmail(), newUser);
                //response.sendRedirect("index.jsp");
                dispatcher(request, response, "index.jsp");
            }

        }
    }

}

From source file:catalina.core.StandardServer.java

/**
 * Store the specified NamingResources properties.
 *
 * @param writer PrintWriter to which we are storing
 * @param indent Number of spaces to indent this element
 * @param resources Object whose properties are being stored
 *
 * @exception Exception if an exception occurs while storing
 *///w  w  w . j av a2  s  .  c o m
private void storeNamingResources(PrintWriter writer, int indent, NamingResources resources) throws Exception {

    // Store nested <Ejb> elements
    ContextEjb[] ejbs = resources.findEjbs();
    if (ejbs.length > 0) {
        for (int i = 0; i < ejbs.length; i++) {
            for (int j = 0; j < indent; j++) {
                writer.print(' ');
            }
            writer.print("<Ejb");
            storeAttributes(writer, false, ejbs[i]);
            writer.println("/>");
        }
    }

    // Store nested <Environment> elements
    ContextEnvironment[] envs = resources.findEnvironments();
    if (envs.length > 0) {
        for (int i = 0; i < envs.length; i++) {
            for (int j = 0; j < indent; j++) {
                writer.print(' ');
            }
            writer.print("<Environment");
            storeAttributes(writer, false, envs[i]);
            writer.println("/>");
        }
    }

    // Store nested <LocalEjb> elements
    ContextLocalEjb[] lejbs = resources.findLocalEjbs();
    if (lejbs.length > 0) {
        for (int i = 0; i < lejbs.length; i++) {
            for (int j = 0; j < indent; j++) {
                writer.print(' ');
            }
            writer.print("<LocalEjb");
            storeAttributes(writer, false, lejbs[i]);
            writer.println("/>");
        }
    }

    // Store nested <Resource> elements
    ContextResource[] dresources = resources.findResources();
    for (int i = 0; i < dresources.length; i++) {
        for (int j = 0; j < indent; j++) {
            writer.print(' ');
        }
        writer.print("<Resource");
        storeAttributes(writer, false, dresources[i]);
        writer.println("/>");
    }

    // Store nested <ResourceEnvRef> elements
    String[] eresources = resources.findResourceEnvRefs();
    for (int i = 0; i < eresources.length; i++) {
        for (int j = 0; j < indent; j++) {
            writer.print(' ');
        }
        writer.println("<ResourceEnvRef>");
        for (int j = 0; j < indent + 2; j++) {
            writer.print(' ');
        }
        writer.print("<name>");
        writer.print(eresources[i]);
        writer.println("</name>");
        for (int j = 0; j < indent + 2; j++) {
            writer.print(' ');
        }
        writer.print("<type>");
        writer.print(resources.findResourceEnvRef(eresources[i]));
        writer.println("</type>");
        for (int j = 0; j < indent; j++) {
            writer.print(' ');
        }
        writer.println("</ResourceEnvRef>");
    }

    // Store nested <ResourceParams> elements
    ResourceParams[] params = resources.findResourceParams();
    for (int i = 0; i < params.length; i++) {
        for (int j = 0; j < indent; j++) {
            writer.print(' ');
        }
        writer.print("<ResourceParams");
        storeAttributes(writer, false, params[i]);
        writer.println(">");
        Hashtable resourceParams = params[i].getParameters();
        Enumeration nameEnum = resourceParams.keys();
        while (nameEnum.hasMoreElements()) {
            String name = (String) nameEnum.nextElement();
            String value = (String) resourceParams.get(name);
            for (int j = 0; j < indent + 2; j++) {
                writer.print(' ');
            }
            writer.println("<parameter>");
            for (int j = 0; j < indent + 4; j++) {
                writer.print(' ');
            }
            writer.print("<name>");
            writer.print(name);
            writer.println("</name>");
            for (int j = 0; j < indent + 4; j++) {
                writer.print(' ');
            }
            writer.print("<value>");
            writer.print(value);
            writer.println("</value>");
            for (int j = 0; j < indent + 2; j++) {
                writer.print(' ');
            }
            writer.println("</parameter>");
        }
        for (int j = 0; j < indent; j++) {
            writer.print(' ');
        }
        writer.println("</ResourceParams>");
    }

    // Store nested <ResourceLink> elements
    ContextResourceLink[] resourceLinks = resources.findResourceLinks();
    for (int i = 0; i < resourceLinks.length; i++) {
        for (int j = 0; j < indent; j++) {
            writer.print(' ');
        }
        writer.print("<ResourceLink");
        storeAttributes(writer, false, resourceLinks[i]);
        writer.println("/>");
    }

}

From source file:edu.ku.brc.specify.tasks.InfoRequestTask.java

/**
 * Creates an Excel SpreadSheet or CVS file and attaches it to an email and send it to an agent.
 *///w w w. j  av a 2s. c  o  m
public void createAndSendEMail() {
    FormViewObj formViewObj = getCurrentFormViewObj();
    if (formViewObj != null) // Should never happen
    {
        InfoRequest infoRequest = (InfoRequest) formViewObj.getDataObj();
        Agent toAgent = infoRequest.getAgent();

        boolean sendEMailTmp = true; // default to true
        Component comp = formViewObj.getControlByName("sendEMail");
        if (comp instanceof JCheckBox) {
            sendEMailTmp = ((JCheckBox) comp).isSelected();
        }
        final boolean sendEMail = sendEMailTmp;

        MultiView mv = formViewObj.getSubView("InfoRequestColObj");
        if (mv != null && sendEMail) {
            final Viewable viewable = mv.getCurrentView();
            if (viewable instanceof TableViewObj) {
                final Hashtable<String, String> emailPrefs = new Hashtable<String, String>();
                if (!isEMailPrefsOK(emailPrefs)) {
                    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                            getResourceString("NO_EMAIL_PREF_INFO"),
                            getResourceString("NO_EMAIL_PREF_INFO_TITLE"), JOptionPane.WARNING_MESSAGE);
                    return;
                }

                final File tempExcelFileName = TableModel2Excel.getTempExcelName();

                AppPreferences appPrefs = AppPreferences.getLocalPrefs();
                final Hashtable<String, String> values = new Hashtable<String, String>();
                values.put("to", toAgent.getEmail() != null ? toAgent.getEmail() : "");
                values.put("from", appPrefs.get("settings.email.email", ""));
                values.put("subject", String.format(getResourceString("INFO_REQUEST_SUBJECT"),
                        new Object[] { infoRequest.getIdentityTitle() }));
                values.put("bodytext", "");
                values.put("attachedFileName", tempExcelFileName.getName());

                final ViewBasedDisplayDialog dlg = new ViewBasedDisplayDialog((Frame) UIRegistry.getTopWindow(),
                        "SystemSetup", "SendMail", null, getResourceString("SEND_MAIL_TITLE"),
                        getResourceString("SEND_BTN"), null, // className,
                        null, // idFieldName,
                        true, // isEdit,
                        0);
                dlg.setData(values);
                dlg.setModal(true);
                dlg.setVisible(true);
                if (dlg.getBtnPressed() == ViewBasedDisplayIFace.OK_BTN) {
                    dlg.getMultiView().getDataFromUI();

                    //System.out.println("["+values.get("bodytext")+"]");

                    TableViewObj tblViewObj = (TableViewObj) viewable;
                    File excelFile = TableModel2Excel.convertToExcel(tempExcelFileName,
                            getResourceString("CollectionObject"), tblViewObj.getTable().getModel());
                    StringBuilder sb = TableModel2Excel.convertToHTML(getResourceString("CollectionObject"),
                            tblViewObj.getTable().getModel());

                    //EMailHelper.setDebugging(true);
                    String text = values.get("bodytext").replace("\n", "<br>") + "<BR><BR>" + sb.toString();

                    // XXX need to move the invokdeLater into the UIRegistry
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            UIRegistry.displayLocalizedStatusBarText("SENDING_EMAIL");
                        }
                    });

                    if (sendEMail) {
                        final EMailHelper.ErrorType status = EMailHelper.sendMsg(emailPrefs.get("servername"),
                                emailPrefs.get("username"), Encryption.decrypt(emailPrefs.get("password")),
                                emailPrefs.get("email"), values.get("to"), values.get("subject"), text,
                                EMailHelper.HTML_TEXT, emailPrefs.get("port"), emailPrefs.get("security"),
                                excelFile);
                        if (status != EMailHelper.ErrorType.Cancel) {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    UIRegistry.displayLocalizedStatusBarText(
                                            status == EMailHelper.ErrorType.Error ? "EMAIL_SENT_ERROR"
                                                    : "EMAIL_SENT_OK");
                                }
                            });
                        }
                    }
                }
            }
        }
    } else {
        log.error("Why doesn't the current SubPane have a main FormViewObj?");
    }
}

From source file:net.rim.ejde.internal.packaging.PackagingManager.java

private Vector<String> getProtectionOptions(boolean forMakefile) {
    Vector<String> v = new Vector<String>();
    Hashtable<String, String> classProtection, packageProtection;
    classProtection = _bbProject.getProperties()._hiddenProperties.getClassProtection();
    packageProtection = _bbProject.getProperties()._hiddenProperties.getPackageProtection();
    Object keys[] = packageProtection.keySet().toArray();
    for (int i = 0; i < keys.length; ++i) {
        v.addElement("package:" + Util.doubleDollar(keys[i].toString()) + "="
                + stripPath(packageProtection.get(keys[i])));
    }// w  ww . ja v  a2s .c  om
    keys = classProtection.keySet().toArray();
    for (int i = 0; i < keys.length; ++i) {
        if (forMakefile) {
            v.addElement("class:" + Util.doubleDollar(keys[i].toString()) + "="
                    + stripPath(classProtection.get(keys[i])));
        } else {
            // When we are not creating a makefile don't add double $$ to rapc cmd line
            v.addElement("class:" + keys[i].toString() + "=" + stripPath(classProtection.get(keys[i])));
        }
    }
    return v;
}

From source file:org.ramadda.data.services.PointFormHandler.java

/**
 * _more_/*from   w  ww  . j a v  a 2s . c  o m*/
 *
 * @param request _more_
 * @param pointEntry _more_
 * @param plotInfo _more_
 *
 * @return _more_
 *
 * @throws Exception _more_
 */
public BufferedImage makeTimeseriesImage(Request request, PointEntry pointEntry, final PlotInfo plotInfo)
        throws Exception {

    Entry entry = pointEntry.getEntry();
    int width = TIMESERIES_WIDTH;
    int height = TIMESERIES_HEIGHT;
    long numRecords = pointEntry.getNumRecords();
    final int numPointsToPlot = request.get(ARG_NUMPOINTS, TIMESERIES_POINTS);
    final int[] cnt = { 0 };
    final List<TimeSeries> series = new ArrayList<TimeSeries>();

    final List<RecordField> tmpFields = pointEntry.getRecordFile().getChartableFields();

    final List<RecordField> fields = new ArrayList<RecordField>();

    if (request.get(ARG_CHART_SHOW + FIELD_ALTITUDE, false)) {
        fields.add(new RecordField(FIELD_ALTITUDE, LABEL_ALTITUDE, "", -1, UNIT_M));
    }

    for (RecordField attr : tmpFields) {
        if (request.get(ARG_CHART_SHOW + attr.getName(), false)) {
            fields.add(attr);
        }
    }

    if ((fields.size() == 0) && (tmpFields.size() > 0)) {
        fields.add(tmpFields.get(0));
        request.put(ARG_CHART_SHOW + tmpFields.get(0).getName(), "true");
    }

    for (RecordField attr : fields) {
        series.add(new TimeSeries(attr.getLabel()));
    }

    RecordVisitor visitor = new BridgeRecordVisitor(getOutputHandler()) {
        public boolean doVisitRecord(RecordFile file, VisitInfo visitInfo, Record record) {
            PointRecord pointRecord = (PointRecord) record;
            for (int fieldCnt = 0; fieldCnt < fields.size(); fieldCnt++) {
                RecordField field = fields.get(fieldCnt);
                double value;
                //Check for altitude
                if (field.getParamId() < 0) {
                    value = pointRecord.getAltitude();
                } else {
                    value = record.getValue(field.getParamId());
                }
                long time = record.getRecordTime();
                series.get(fieldCnt).add(new FixedMillisecond(time), value);
            }
            plotInfo.setIndex(pointRecord.index);
            cnt[0]++;

            return true;
        }
    };

    long t1 = System.currentTimeMillis();
    int skip = (int) (numRecords / numPointsToPlot);
    getRecordJobManager().visitSequential(request, pointEntry, visitor, new VisitInfo(skip));
    long t2 = System.currentTimeMillis();

    JFreeChart chart = createTimeseriesChart(request, entry, new TimeSeriesCollection(), null);
    long t3 = System.currentTimeMillis();
    XYPlot plot = (XYPlot) chart.getPlot();
    int lineCnt = 0;
    int[] colorCnt = { 0 };
    int numberOfAxisLegends = 0;

    Hashtable<String, double[]> valueRanges = new Hashtable<String, double[]>();

    for (int extraCnt = 0; extraCnt < series.size(); extraCnt++) {
        TimeSeries timeSeries = series.get(extraCnt);
        RecordField field = fields.get(extraCnt);
        String unit = field.getUnit();
        if ((unit != null) && (unit.length() == 0)) {
            unit = null;
        }

        if (unit == null) {
            unit = extraCnt + "";
        }
        if (unit == null) {
            continue;
        }
        double max = timeSeries.getMaxY();
        double min = timeSeries.getMinY();
        double[] range = valueRanges.get(unit);
        if (range == null) {
            range = new double[] { min, max };
            valueRanges.put(unit, range);
        } else {
            range[0] = Math.min(range[0], min);
            range[1] = Math.max(range[1], max);
        }
    }

    Hashtable<String, NumberAxis> seenAxis = new Hashtable<String, NumberAxis>();
    for (int extraCnt = 0; extraCnt < series.size(); extraCnt++) {
        TimeSeries timeSeries = series.get(extraCnt);
        RecordField field = fields.get(extraCnt);

        String unit = field.getUnit();
        if ((unit != null) && (unit.length() == 0)) {
            unit = null;
        }

        TimeSeriesCollection dataset2 = new TimeSeriesCollection();
        dataset2.addSeries(timeSeries);
        NumberAxis axis = new NumberAxis(field.getLabel());
        numberOfAxisLegends++;
        if (unit != null) {
            double[] range = valueRanges.get(unit);
            axis.setRange(range[0], range[1]);
            NumberAxis seenOne = seenAxis.get(unit);
            if (seenOne == null) {
                seenAxis.put(unit, axis);
            } else {
                seenOne.setLabel(seenOne.getLabel() + "/" + field.getLabel());
                axis.setVisible(false);
                numberOfAxisLegends--;
            }
        } else {
            axis.setAutoRange(true);
            axis.setAutoRangeIncludesZero(true);
        }

        plot.setRangeAxis(lineCnt, axis);
        plot.setDataset(lineCnt, dataset2);
        plot.mapDatasetToRangeAxis(lineCnt, lineCnt);
        plot.setRangeAxisLocation(lineCnt, AxisLocation.BOTTOM_OR_RIGHT);

        StandardXYItemRenderer renderer = new MyStandardXYItemRenderer(plotInfo);
        renderer.setSeriesPaint(0, getColor(request, ARG_CHART_COLOR + field.getName(), colorCnt));
        plot.setRenderer(lineCnt, renderer);
        lineCnt++;
    }

    AxisSpace axisSpace = new AxisSpace();
    axisSpace.setRight(TIMESERIES_AXIS_WIDTHPER * numberOfAxisLegends);
    plot.setFixedRangeAxisSpace(axisSpace);

    long t4 = System.currentTimeMillis();
    BufferedImage newImage = chart.createBufferedImage(width + (numberOfAxisLegends * TIMESERIES_AXIS_WIDTHPER),
            height);

    long t5 = System.currentTimeMillis();

    //        System.err.println("Time series  cnt:" + cnt[0] + " " + (t2 - t1) + " "  + (t3 - t2) + " " + (t4 - t3) + " " + (t5 - t4));
    return newImage;
}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java

protected Vector<FormCellLabel> getAvailableLabels() {
    Vector<FormCellLabel> list = new Vector<FormCellLabel>();
    Hashtable<String, FormCellLabel> labelHash = new Hashtable<String, FormCellLabel>();
    //Hashtable<String, FormCellLabel> labelForHash = new Hashtable<String, FormCellLabel>();
    // Add all the labels
    for (FormRowIFace row : formViewDef.getRows()) {
        for (FormCellIFace cell : row.getCells()) {
            if (cell instanceof FormCellLabel) {
                //labelForHash.put(((FormCellLabel)cell).getLabelFor(), (FormCellLabel)cell);
                labelHash.put(cell.getIdent(), (FormCellLabel) cell);
            }// w  ww  .  j  a va  2  s . c o m
        }
    }

    // remove the ones in use
    for (FormRowIFace row : formViewDef.getRows()) {
        for (FormCellIFace cell : row.getCells()) {
            if (cell instanceof FormCellField) {
                FormCellField fcf = (FormCellField) cell;
                FormCellLabel label = labelHash.get(fcf.getIdent());
                if (label != null) {
                    labelHash.remove(label.getIdent());
                }
            }
        }
    }
    list.addAll(labelHash.values());
    return list;
}

From source file:ch.elexis.data.TarmedOptifier.java

/**
 * Eine Verrechnungsposition zufgen. Der Optifier muss prfen, ob die Verrechnungsposition im
 * Kontext der bergebenen Konsultation verwendet werden kann und kann sie ggf. zurckweisen
 * oder modifizieren./*from w ww . j  a va  2s .  co m*/
 */

public Result<IVerrechenbar> add(IVerrechenbar code, Konsultation kons) {
    if (!(code instanceof TarmedLeistung)) {
        return new Result<IVerrechenbar>(Result.SEVERITY.ERROR, LEISTUNGSTYP, Messages.TarmedOptifier_BadType,
                null, true);
    }

    bOptify = CoreHub.userCfg.get(Preferences.LEISTUNGSCODES_OPTIFY, true);

    TarmedLeistung tc = (TarmedLeistung) code;
    List<Verrechnet> lst = kons.getLeistungen();
    /*
     * TODO Hier checken, ob dieser code mit der Dignitt und
     * Fachspezialisierung des aktuellen Mandanten usw. vereinbar ist
     */

    Hashtable<String, String> ext = tc.loadExtension();

    // Gltigkeit gemss Datum und Alter prfen
    if (bOptify) {
        TimeTool date = new TimeTool(kons.getDatum());
        String dVon = ((TarmedLeistung) code).get("GueltigVon"); //$NON-NLS-1$
        if (!StringTool.isNothing(dVon)) {
            TimeTool tVon = new TimeTool(dVon);
            if (date.isBefore(tVon)) {
                return new Result<IVerrechenbar>(Result.SEVERITY.WARNING, NOTYETVALID,
                        code.getCode() + Messages.TarmedOptifier_NotYetValid, null, false);
            }
        }
        String dBis = ((TarmedLeistung) code).get("GueltigBis"); //$NON-NLS-1$
        if (!StringTool.isNothing(dBis)) {
            TimeTool tBis = new TimeTool(dBis);
            if (date.isAfter(tBis)) {
                return new Result<IVerrechenbar>(Result.SEVERITY.WARNING, NOMOREVALID,
                        code.getCode() + Messages.TarmedOptifier_NoMoreValid, null, false);
            }
        }
        String ageLimits = ext.get(TarmedLeistung.EXT_FLD_SERVICE_AGE);
        if (ageLimits != null && !ageLimits.isEmpty()) {
            String errorMessage = checkAge(ageLimits, kons);
            if (errorMessage != null) {
                return new Result<IVerrechenbar>(Result.SEVERITY.WARNING, PATIENTAGE, errorMessage, null,
                        false);
            }
        }
    }
    newVerrechnet = null;
    newVerrechnetSide = null;
    // Korrekter Fall Typ prfen, und ggf. den code ndern
    if (tc.getCode().matches("39.002[01]") || tc.getCode().matches("39.001[0156]")) {
        String gesetz = kons.getFall().getConfiguredBillingSystemLaw().name();
        if (gesetz == null || gesetz.isEmpty()) {
            gesetz = kons.getFall().getAbrechnungsSystem();
        }

        if (gesetz.equalsIgnoreCase("KVG") && tc.getCode().matches("39.0011")) {
            return this.add(getKonsVerrechenbar("39.0010", kons), kons);
        } else if (!gesetz.equalsIgnoreCase("KVG") && tc.getCode().matches("39.0010")) {
            return this.add(getKonsVerrechenbar("39.0011", kons), kons);
        }

        if (gesetz.equalsIgnoreCase("KVG") && tc.getCode().matches("39.0016")) {
            return this.add(getKonsVerrechenbar("39.0015", kons), kons);
        } else if (!gesetz.equalsIgnoreCase("KVG") && tc.getCode().matches("39.0015")) {
            return this.add(getKonsVerrechenbar("39.0016", kons), kons);
        }

        if (gesetz.equalsIgnoreCase("KVG") && tc.getCode().matches("39.0021")) {
            return this.add(getKonsVerrechenbar("39.0020", kons), kons);
        } else if (!gesetz.equalsIgnoreCase("KVG") && tc.getCode().matches("39.0020")) {
            return this.add(getKonsVerrechenbar("39.0021", kons), kons);
        }
    }

    if (tc.getCode().matches("35.0020")) {
        List<Verrechnet> opCodes = getOPList(lst);
        List<Verrechnet> opReduction = getVerrechnetMatchingCode(lst, "35.0020");
        // updated reductions to codes, and get not yet reduced codes
        List<Verrechnet> availableCodes = updateOPReductions(opCodes, opReduction);
        if (availableCodes.isEmpty()) {
            return new Result<IVerrechenbar>(Result.SEVERITY.WARNING, KOMBINATION, code.getCode(), null, false);
        }
        for (Verrechnet verrechnet : availableCodes) {
            newVerrechnet = new Verrechnet(tc, kons, 1);
            mapOpReduction(verrechnet, newVerrechnet);
        }
        return new Result<IVerrechenbar>(null);
    }

    // Ist der Hinzuzufgende Code vielleicht schon in der Liste? Dann
    // nur Zahl erhhen.
    for (Verrechnet v : lst) {
        if (v.isInstance(code)) {
            if (!tc.requiresSide()) {
                newVerrechnet = v;
                newVerrechnet.setZahl(newVerrechnet.getZahl() + 1);
                break;
            }
        }
    }

    if (tc.requiresSide()) {
        newVerrechnetSide = getNewVerrechnetSideOrIncrement(code, lst);
    }

    // Ausschliessende Kriterien prfen ("Nicht zusammen mit")
    if (newVerrechnet == null) {
        newVerrechnet = new Verrechnet(code, kons, 1);
        // make sure side is initialized
        if (tc.requiresSide()) {
            newVerrechnet.setDetail(TarmedLeistung.SIDE, newVerrechnetSide);
        }
        // Exclusionen
        if (bOptify) {
            TarmedLeistung newTarmed = (TarmedLeistung) code;
            for (Verrechnet v : lst) {
                if (v.getVerrechenbar() instanceof TarmedLeistung) {
                    TarmedLeistung tarmed = (TarmedLeistung) v.getVerrechenbar();
                    if (tarmed != null && tarmed.exists()) {
                        // check if new has an exclusion for this verrechnet
                        // tarmed
                        Result<IVerrechenbar> resCompatible = isCompatible(v, tarmed, newVerrechnet, newTarmed,
                                kons);
                        if (resCompatible.isOK()) {
                            // check if existing tarmed has exclusion for
                            // new one
                            resCompatible = isCompatible(newVerrechnet, newTarmed, v, tarmed, kons);
                        }

                        if (!resCompatible.isOK()) {
                            newVerrechnet.delete();
                            return resCompatible;
                        }
                    }
                }
            }

            if (newVerrechnet.getCode().equals("00.0750") || newVerrechnet.getCode().equals("00.0010")) {
                String excludeCode = null;
                if (newVerrechnet.getCode().equals("00.0010")) {
                    excludeCode = "00.0750";
                } else {
                    excludeCode = "00.0010";
                }
                for (Verrechnet v : lst) {
                    if (v.getCode().equals(excludeCode)) {
                        newVerrechnet.delete();
                        return new Result<IVerrechenbar>(Result.SEVERITY.WARNING, EXKLUSION,
                                "00.0750 ist nicht im Rahmen einer rztlichen Beratung 00.0010 verrechnenbar.", //$NON-NLS-1$
                                null, false);
                    }
                }
            }
        }
        newVerrechnet.setDetail(AL, Integer.toString(tc.getAL(kons.getMandant())));
        setALScalingInfo(tc, newVerrechnet, kons.getMandant(), false);
        newVerrechnet.setDetail(TL, Integer.toString(tc.getTL()));
        lst.add(newVerrechnet);
    }

    // set bezug of zuschlagsleistung and referenzleistung
    if (isReferenceInfoAvailable() && shouldDetermineReference(tc)) {
        // lookup available masters
        List<Verrechnet> masters = getPossibleMasters(newVerrechnet, lst);
        if (masters.isEmpty()) {
            decrementOrDelete(newVerrechnet);
            return new Result<IVerrechenbar>(Result.SEVERITY.WARNING, KOMBINATION, "Fr die Zuschlagsleistung "
                    + code.getCode() + " konnte keine passende Hauptleistung gefunden werden.", null, false);
        }
        if (!masters.isEmpty()) {
            String bezug = newVerrechnet.getDetail("Bezug");
            if (bezug == null) {
                // set bezug to first available master
                newVerrechnet.setDetail("Bezug", masters.get(0).getCode());
            } else {
                boolean found = false;
                // lookup matching, or create new Verrechnet
                for (Verrechnet mVerr : masters) {
                    if (mVerr.getCode().equals(bezug)) {
                        // just mark as found as amount is already increased
                        found = true;
                    }
                }
                if (!found) {
                    // create a new Verrechent and decrease amount
                    newVerrechnet.setZahl(newVerrechnet.getZahl() - 1);
                    newVerrechnet = new Verrechnet(code, kons, 1);
                    newVerrechnet.setDetail("Bezug", masters.get(0).getCode());
                }
            }
        }
    }

    Result<IVerrechenbar> limitResult = checkLimitations(kons, tc, newVerrechnet);
    if (!limitResult.isOK()) {
        decrementOrDelete(newVerrechnet);
        return limitResult;
    }

    String tcid = code.getCode();

    // check if it's an X-RAY service and add default tax if so
    // default xray tax will only be added once (see above)
    if (!tc.getCode().equals(DEFAULT_TAX_XRAY_ROOM) && !tc.getCode().matches("39.002[01]")
            && tc.getParent().startsWith(CHAPTER_XRAY)) {
        if (CoreHub.userCfg.get(Preferences.LEISTUNGSCODES_OPTIFY_XRAY, true)) {
            add(getKonsVerrechenbar(DEFAULT_TAX_XRAY_ROOM, kons), kons);
            // add 39.0020, will be changed according to case (see above)
            add(getKonsVerrechenbar("39.0020", kons), kons);
        }
    }

    // Interventionelle Schmerztherapie: Zuschlag cervical und thoracal
    else if (tcid.equals("29.2090")) {
        double sumAL = 0.0;
        double sumTL = 0.0;
        for (Verrechnet v : lst) {
            if (v.getVerrechenbar() instanceof TarmedLeistung) {
                TarmedLeistung tl = (TarmedLeistung) v.getVerrechenbar();
                String tlc = tl.getCode();
                double z = v.getZahl();
                if (tlc.matches("29.20[12345678]0") || (tlc.equals("29.2200"))) {
                    sumAL += (z * tl.getAL(kons.getMandant())) / 2;
                    sumTL += (z * tl.getTL()) / 4;
                }
            }
        }
        newVerrechnet.setTP(sumAL + sumTL);
        newVerrechnet.setDetail(AL, Double.toString(sumAL));
        newVerrechnet.setDetail(TL, Double.toString(sumTL));
    }

    // Zuschlag Kinder
    else if (tcid.equals("00.0010") || tcid.equals("00.0060")) {
        if (CoreHub.mandantCfg != null && CoreHub.mandantCfg.get(RechnungsPrefs.PREF_ADDCHILDREN, false)) {
            Fall f = kons.getFall();
            if (f != null) {
                Patient p = f.getPatient();
                if (p != null) {
                    String alter = p.getAlter();
                    if (Integer.parseInt(alter) < 6) {
                        TarmedLeistung tl = (TarmedLeistung) getKonsVerrechenbar("00.0040", kons);
                        add(tl, kons);
                    }
                }
            }
        }
    }

    // Zuschlge fr Insellappen 50% auf AL und TL bei 1910,20,40,50
    else if (tcid.equals("04.1930")) { //$NON-NLS-1$
        double sumAL = 0.0;
        double sumTL = 0.0;
        for (Verrechnet v : lst) {
            if (v.getVerrechenbar() instanceof TarmedLeistung) {
                TarmedLeistung tl = (TarmedLeistung) v.getVerrechenbar();
                String tlc = tl.getCode();
                int z = v.getZahl();
                if (tlc.equals("04.1910") || tlc.equals("04.1920") || tlc.equals("04.1940") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        || tlc.equals("04.1950")) { //$NON-NLS-1$
                    sumAL += tl.getAL(kons.getMandant()) * z;
                    sumTL += tl.getTL() * z;
                    // double al = (tl.getAL() * 15) / 10.0;
                    // double tel = (tl.getTL() * 15) / 10.0;
                    // sum += al * z;
                    // sum += tel * z;
                }
            }
        }
        // sum = sum * factor / 100.0;
        // check.setPreis(new Money(sum));
        newVerrechnet.setTP(sumAL + sumTL);
        newVerrechnet.setDetail(AL, Double.toString(sumAL));
        newVerrechnet.setDetail(TL, Double.toString(sumTL));
        newVerrechnet.setPrimaryScaleFactor(0.5);
    }
    // Zuschlge fr 04.0620 sollte sich diese mit 70% auf die Positionen 04.0630 & 04.0640 beziehen
    else if (tcid.equals("04.0620")) {
        double sumAL = 0.0;
        double sumTL = 0.0;
        for (Verrechnet v : lst) {
            if (v.getVerrechenbar() instanceof TarmedLeistung) {
                TarmedLeistung tl = (TarmedLeistung) v.getVerrechenbar();
                String tlc = tl.getCode();
                int z = v.getZahl();
                if (tlc.equals("04.0610") || tlc.equals("04.0630") || tlc.equals("04.0640")) {
                    sumAL += tl.getAL(kons.getMandant()) * z;
                    sumTL += tl.getTL() * z;
                }
            }
        }
        newVerrechnet.setTP(sumAL + sumTL);
        newVerrechnet.setDetail(AL, Double.toString(sumAL));
        newVerrechnet.setDetail(TL, Double.toString(sumTL));
        newVerrechnet.setPrimaryScaleFactor(0.7);
    }

    // Notfall-Zuschlge
    if (tcid.startsWith("00.25")) { //$NON-NLS-1$
        double sum = 0.0;
        int subcode = Integer.parseInt(tcid.substring(5));
        switch (subcode) {
        case 10: // Mo-Fr 7-19, Sa 7-12: 60 TP
            break;
        case 20: // Mo-Fr 19-22, Sa 12-22, So 7-22: 120 TP
            break;
        case 30: // 25% zu allen AL von 20
        case 70: // 25% zu allen AL von 60 (tel.)
            for (Verrechnet v : lst) {
                if (v.getVerrechenbar() instanceof TarmedLeistung) {
                    TarmedLeistung tl = (TarmedLeistung) v.getVerrechenbar();
                    if (tl.getCode().startsWith("00.25")) { //$NON-NLS-1$
                        continue;
                    }
                    sum += (tl.getAL(kons.getMandant()) * v.getZahl());
                    // int summand = tl.getAL() >> 2; // TODO ev. float?
                    // -> Rundung?
                    // ((sum.addCent(summand * v.getZahl());
                }
            }
            // check.setPreis(sum.multiply(factor));
            newVerrechnet.setTP(sum);
            newVerrechnet.setDetail(AL, Double.toString(sum));
            newVerrechnet.setPrimaryScaleFactor(0.25);
            break;
        case 40: // 22-7: 180 TP
            break;
        case 50: // 50% zu allen AL von 40
        case 90: // 50% zu allen AL von 70 (tel.)
            for (Verrechnet v : lst) {
                if (v.getVerrechenbar() instanceof TarmedLeistung) {
                    TarmedLeistung tl = (TarmedLeistung) v.getVerrechenbar();
                    if (tl.getCode().startsWith("00.25")) { //$NON-NLS-1$
                        continue;
                    }
                    // int summand = tl.getAL() >> 1;
                    // sum.addCent(summand * v.getZahl());
                    sum += (tl.getAL(kons.getMandant()) * v.getZahl());
                }
            }
            // check.setPreis(sum.multiply(factor));
            newVerrechnet.setTP(sum);
            newVerrechnet.setDetail(AL, Double.toString(sum));
            newVerrechnet.setPrimaryScaleFactor(0.5);
            break;

        case 60: // Tel. Mo-Fr 19-22, Sa 12-22, So 7-22: 30 TP
            break;
        case 80: // Tel. von 22-7: 70 TP
            break;

        }
        return new Result<IVerrechenbar>(Result.SEVERITY.OK, PREISAENDERUNG, "Preis", null, false); //$NON-NLS-1$
    }
    return new Result<IVerrechenbar>(null);
}

From source file:edu.ku.brc.specify.dbsupport.BuildFromGeonames.java

/**
 * Builds the Geography tree from the geonames table.
 * @param earthId the id of the root./*from w  w w .  j  a v a2s. co m*/
 * @return true on success
 */
public boolean build(final int earthId) {
    Statement stmt = null;
    try {
        DBConnection currDBConn = DBConnection.getInstance();
        if (updateConn == null) {
            updateConn = currDBConn.createConnection();
        }
        pStmt = updateConn.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS);

        readConn = currDBConn.createConnection();

        stmt = readConn.createStatement();

        Integer count = BasicSQLUtils.getCount(readConn, CNT_SQL);
        doProgress(0, count, "Initializing Reference Geography...");

        Hashtable<String, String> continentCodeFromName = new Hashtable<String, String>();
        ResultSet rs = stmt.executeQuery("SELECT code, name from continentcodes");
        while (rs.next()) {
            continentNameFromCode.put(rs.getString(1), rs.getString(2));
            continentCodeFromName.put(rs.getString(2), rs.getString(1));
        }
        rs.close();

        /*if (false) // For testing
        {
        int delCnt = BasicSQLUtils.update(currConn, "DELETE FROM geography WHERE GeographyID > 1 AND RankId = 400");
        log.debug("Deleted "+delCnt+" geography records.");
        delCnt = BasicSQLUtils.update(currConn, "DELETE FROM geography WHERE GeographyID > 1 AND RankId = 300");
        log.debug("Deleted "+delCnt+" geography records.");
        delCnt = BasicSQLUtils.update(currConn, "DELETE FROM geography WHERE GeographyID > 1 AND RankId = 200");
        log.debug("Deleted "+delCnt+" geography records.");
        delCnt = BasicSQLUtils.update(currConn, "DELETE FROM geography WHERE GeographyID > 1 AND RankId = 100");
        log.debug("Deleted "+delCnt+" geography records.");
        }*/

        doProgress("Initializing Reference Continents..."); // I18N

        String earthSQL = "UPDATE geography SET GeographyCode='..' WHERE GeographyID = " + earthId;
        BasicSQLUtils.update(earthSQL);

        int cnt = 0;

        //////////////////////
        // Continent
        //////////////////////
        String sqlStr = "SELECT continentcodes.name, geoname.latitude, geoname.longitude, continentcodes.code FROM geoname Inner Join continentcodes ON geoname.name = continentcodes.name";
        rs = stmt.executeQuery(sqlStr);
        while (rs.next()) {
            doProgress(cnt);

            if (buildInsert(rs, 100, earthId)) {
                pStmt.executeUpdate();
                Integer newId = BasicSQLUtils.getInsertedId(pStmt);
                contToIdHash.put(rs.getString(4), newId);
            }

            cnt++;
            if (cnt % 100 == 0) {
                doProgress(cnt);
            }
        }
        rs.close();

        //////////////////////
        // Countries
        //////////////////////

        // Make hash of Country Codes
        HashSet<String> countryCodes = new HashSet<String>();
        rs = stmt.executeQuery("SELECT DISTINCT country FROM geoname WHERE fcode = 'PCLI'");
        while (rs.next()) {
            countryCodes.add(rs.getString(1));
        }
        rs.close();

        doProgress("Initializing Reference Countries...");

        // First map all Countries to Continents
        rs = stmt.executeQuery(
                "SELECT name, iso_alpha2 AS CountryCode, continent FROM countryinfo ORDER BY continent, iso_alpha2");
        while (rs.next()) {
            String countryCode = rs.getString(2);
            String continentCode = rs.getString(3);
            countryStateCodeToIdHash.put(countryCode, new Hashtable<String, Integer>());
            countryToContHash.put(countryCode, continentCode);
        }
        rs.close();

        // Now create all the countries in the geoname table
        sqlStr = "SELECT asciiname, latitude, longitude, country FROM geoname WHERE fcode LIKE 'PCL%' ORDER BY name";
        rs = stmt.executeQuery(sqlStr);
        while (rs.next()) {
            if (buildInsert(rs, 200, earthId)) {
                pStmt.executeUpdate();
                Integer newId = BasicSQLUtils.getInsertedId(pStmt);
                countryCodeToIdHash.put(rs.getString(4), newId);
            }

            cnt++;
            if (frame != null && cnt % 100 == 0) {
                doProgress(cnt);
            }

        }
        rs.close();

        // Create an Countries that referenced in the geoname table
        rs = stmt.executeQuery(
                "SELECT name, iso_alpha2 AS CountryCode, continent, iso_alpha2 FROM countryinfo ORDER BY continent, iso_alpha2");
        while (rs.next()) {
            String countryCode = rs.getString(2);
            String continentCode = rs.getString(3);

            if (BasicSQLUtils.getCountAsInt("SELECT COUNT(*) FROM geography WHERE RankID = 200 AND Abbrev = '"
                    + countryCode + "'") == 0) {
                String countryName = rs.getString(1);

                log.error("Adding country[" + countryName + "][" + countryCode + "][" + continentCode + "]");

                createCountry(countryName, countryCode, continentCode, 200);

                pStmt.executeUpdate();
                Integer newId = BasicSQLUtils.getInsertedId(pStmt);
                countryCodeToIdHash.put(countryCode, newId);
            }
        }
        rs.close();

        doProgress("Initializing Reference States...");

        //////////////////////
        // States
        //////////////////////
        sqlStr = "SELECT asciiname, latitude, longitude, country, admin1 as StateCode, ISOCode FROM geoname WHERE fcode = 'ADM1' ORDER BY name";
        rs = stmt.executeQuery(sqlStr);
        while (rs.next()) {
            if (buildInsert(rs, 300, earthId)) {
                String nameStr = rs.getString(1);
                String countryCode = rs.getString(4);
                String stateCode = rs.getString(5);

                pStmt.executeUpdate();

                Integer newId = BasicSQLUtils.getInsertedId(pStmt);
                Hashtable<String, Integer> stateToIdHash = countryStateCodeToIdHash.get(countryCode);
                if (stateToIdHash != null) {
                    stateToIdHash.put(stateCode, newId);
                } else {
                    log.error("****** Error - No State for code [" + stateCode + "]  Country: " + countryCode
                            + "   Name: " + nameStr);
                }
            }

            cnt++;
            if (frame != null && cnt % 100 == 0) {
                doProgress(cnt);
            }
        }
        rs.close();

        //-------------------------------------------------------------
        // Create States that are referenced by Counties in Countries
        //-------------------------------------------------------------
        sqlStr = "SELECT asciiname AS CountyName, latitude, longitude, country, admin1 as StateCode, ISOCode FROM geoname WHERE fcode = 'ADM2' ORDER BY name";
        rs = stmt.executeQuery(sqlStr);
        while (rs.next()) {
            String countryCode = rs.getString(4);
            String stateCode = rs.getString(5);

            Hashtable<String, Integer> stateToIdHash = countryStateCodeToIdHash.get(countryCode);
            if (stateToIdHash != null && stateToIdHash.get(stateCode) == null) {
                rowData.clear();
                rowData.add(rs.getString(1)); // State Name, same as Code
                rowData.add(new BigDecimal(-1000));
                rowData.add(new BigDecimal(-1000));
                rowData.add(countryCode);
                rowData.add(stateCode);
                rowData.add(rs.getString(6));

                if (buildInsert(rowData, 300, earthId)) {
                    log.debug("Adding State [" + rs.getString(1) + "][" + stateCode + "] for Country ["
                            + countryCode + "]");

                    pStmt.executeUpdate();
                    Integer newId = BasicSQLUtils.getInsertedId(pStmt);
                    stateToIdHash.put(stateCode, newId);
                }
            }

            /*cnt++;
            if (frame != null && cnt % 100 == 0)
            {
            doProgress(cnt);
            }*/

        }
        rs.close();

        doProgress("Initializing Reference Counties...");

        //////////////////////
        // County
        //////////////////////
        sqlStr = "SELECT asciiname, latitude, longitude, country, admin1 as StateCode, ISOCode FROM geoname WHERE fcode = 'ADM2' ORDER BY name";
        rs = stmt.executeQuery(sqlStr);
        while (rs.next()) {
            if (buildInsert(rs, 400, earthId)) {
                pStmt.executeUpdate();
            }

            cnt++;
            if (frame != null && cnt % 100 == 0) {
                doProgress(cnt);
            }
        }
        rs.close();

        doProgress(count);

        return true;

    } catch (Exception ex) {
        ex.printStackTrace();
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BuildFromGeonames.class, ex);

        try {
            updateConn.rollback();

        } catch (Exception exr) {
            exr.printStackTrace();
        }
    } finally {
        try {
            if (stmt != null) {
                stmt.close();
            }
            if (readConn != null) {
                readConn.close();
            }
            if (pStmt != null) {
                pStmt.close();
            }
            if (updateConn != DBConnection.getInstance()) {
                updateConn.close();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    if (frame != null) {
        frame.setVisible(false);
    }
    return false;
}

From source file:at.ac.tuwien.auto.iotsys.gateway.connectors.knx.KNXDeviceLoaderETSImpl.java

private void parseFunctionalView(HierarchicalConfiguration groupConfig, Obj parent, Network n,
        ObjectBroker objectBroker, Hashtable<String, EntityImpl> entityById,
        Hashtable<String, DatapointImpl> datapointById, KNXConnector knxConnector,
        Hashtable<String, String> groupAddressByDatapointId) {
    for (int groupsIdx = 0; groupsIdx < sizeOfConfiguration(
            groupConfig.getProperty("group.[@id]")); groupsIdx++) {
        String groupId = groupConfig.getString("group(" + groupsIdx + ").[@id]");
        String groupName = arrayToString(groupConfig.getStringArray("group(" + groupsIdx + ").[@name]"));
        String groupDescription = arrayToString(
                groupConfig.getStringArray("group(" + groupsIdx + ").[@description]"));
        long groupAddress = groupConfig.getLong("group(" + groupsIdx + ").[@address]");

        GroupImpl group = new GroupImpl(groupId, groupName, groupDescription, groupAddress);

        // add part to parent part
        if (parent instanceof ViewFunctionalImpl)
            ((ViewFunctionalImpl) parent).addGroup(group);
        else if (parent instanceof GroupImpl)
            ((GroupImpl) parent).addGroup(group);
        else/*ww  w  .  j av  a 2  s.c o m*/
            parent.add(group);

        objectBroker.addObj(group, true);

        // add instances to part
        HierarchicalConfiguration concreteGroup = groupConfig.configurationAt("group(" + groupsIdx + ")");

        for (int instanceIdx = 0; instanceIdx < sizeOfConfiguration(
                concreteGroup.getProperty("instance.[@id]")); instanceIdx++) {
            String instanceId = concreteGroup.getString("instance(" + instanceIdx + ").[@id]");
            String connector = concreteGroup.getString("instance(" + instanceIdx + ").[@connector]");

            try {
                DatapointImpl dp = datapointById.get(instanceId);
                if (dp == null) {
                    log.warning("No datapoint type found for instance: " + instanceId);
                    continue;
                }
                Class<?> clazz = dp.getClass();

                if (clazz != null) {
                    Constructor<?> constructor = clazz.getConstructor(KNXConnector.class, DataPointInit.class);
                    Object[] object = new Object[2];
                    object[0] = knxConnector;

                    DataPointInit dptInit = new DataPointInit();
                    dptInit.setName("function");
                    dptInit.setReadable(dp.isValueReadable());
                    dptInit.setWritable(dp.isValueWritable());
                    dptInit.setGroupAddress(
                            new GroupAddress(Integer.parseInt(groupAddressByDatapointId.get(instanceId))));

                    object[1] = dptInit;
                    DatapointImpl dataPoint = (DatapointImpl) constructor.newInstance(object);

                    group.addFunction(dataPoint);
                    objectBroker.addObj(dataPoint, true);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            group.addInstance(datapointById.get(instanceId), connector);
        }

        // recursively add more parts
        parseFunctionalView(concreteGroup, group, n, objectBroker, entityById, datapointById, knxConnector,
                groupAddressByDatapointId);
    }
}