Example usage for java.util Collection addAll

List of usage examples for java.util Collection addAll

Introduction

In this page you can find the example usage for java.util Collection addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this collection (optional operation).

Usage

From source file:com.googlecode.fightinglayoutbugs.FightingLayoutBugs.java

/**
 * Runs all registered {@link LayoutBugDetector}s. Before you call this method, you might:<ul>
 * <li>register new detectors via {@link #enable},</li>
 * <li>remove unwanted detectors via {@link #disable},</li>
 * <li>configure a registered detector via {@link #configure},</li>
 * <li>configure the {@link TextDetector} to be used via {@link #setTextDetector},</li>
 * <li>configure the {@link EdgeDetector} to be used via {@link #setEdgeDetector}.</li>
 * </ul>//w  ww  . ja  v  a 2 s . c  om
 */
public Collection<LayoutBug> findLayoutBugsIn(@Nonnull WebPage webPage) {
    if (webPage == null) {
        throw new IllegalArgumentException("Method parameter webPage must not be null.");
    }
    if (_debugMode) {
        setLogLevelToDebug();
        registerDebugListener();
    }
    try {
        TextDetector textDetector = (_textDetector == null ? new AnimationAwareTextDetector() : _textDetector);
        EdgeDetector edgeDetector = (_edgeDetector == null ? new SimpleEdgeDetector() : _edgeDetector);
        try {
            LOG.debug("Analyzing " + webPage.getUrl() + " ...");
            webPage.setTextDetector(textDetector);
            webPage.setEdgeDetector(edgeDetector);
            final Collection<LayoutBug> result = new ArrayList<LayoutBug>();
            for (LayoutBugDetector detector : _detectors) {
                detector.setScreenshotDir(screenshotDir);
                LOG.debug("Running " + detector.getClass().getSimpleName() + " ...");
                result.addAll(detector.findLayoutBugsIn(webPage));
            }
            if (!result.isEmpty()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Detected layout bug(s) on ").append(webPage.getUrl()).append("\n");
                if (_debugMode) {
                    sb.append(
                            "If there is a false positive, please send an email to fighting-layout-bugs@googlegroups.com with the following information:\n");
                    sb.append("    - your test code,\n");
                    sb.append("    - all logged output, and\n");
                    sb.append("    - all screenshot files located in: ").append(screenshotDir);
                    sb.append("      (You might want to pack those into an zip archive)\n");
                    sb.append("TextDetector: ").append(textDetector.getClass().getName()).append("\n");
                    sb.append("EdgeDetector: ").append(edgeDetector.getClass().getName()).append("\n");
                    sb.append(DebugHelper.getDiagnosticInfo(webPage.getDriver()));
                } else {
                    sb.append(
                            "If you call FightingLayoutBugs.enableDebugMode() before you call FightingLayoutBugs.findLayoutBugsIn(...) you can get more information.");
                }
                LOG.info(sb.toString());
            }
            return result;
        } catch (RuntimeException e) {
            String url = null;
            try {
                url = webPage.getUrl().toString();
            } catch (Exception ignored) {
            }
            StringBuilder sb = new StringBuilder();
            sb.append("Failed to analyze ").append(url == null ? "given WebPage" : url).append(" -- ")
                    .append(e.toString()).append("\n");
            if (_debugMode) {
                sb.append(
                        "If you want support (or want to support FLB) you can send an email to fighting-layout-bugs@googlegroups.com with the following information:\n");
                sb.append("    - your test code,\n");
                sb.append("    - all logged output, and\n");
                sb.append("    - all screenshot files located in: ").append(screenshotDir);
                sb.append("      (You might want to pack those into an zip archive)\n");
                sb.append("TextDetector: ").append(textDetector.getClass().getName()).append("\n");
                sb.append("EdgeDetector: ").append(edgeDetector.getClass().getName()).append("\n");
                sb.append(DebugHelper.getDiagnosticInfo(webPage.getDriver()));
            } else {
                sb.append(
                        "If you call FightingLayoutBugs.enableDebugMode() before you call FightingLayoutBugs.findLayoutBugsIn(...) you can get more information.");
            }
            String errorMessage = sb.toString();
            LOG.error(errorMessage);
            throw new RuntimeException(errorMessage, e);
        }
    } finally {
        for (Runnable runnable : _runAfterAnalysis) {
            try {
                runnable.run();
            } catch (RuntimeException e) {
                LOG.warn(runnable + " failed.", e);
            }
        }
    }
}

From source file:com.gzj.tulip.jade.statement.SelectQuerier.java

protected ResultConverter makeResultConveter() {
    ResultConverter converter;//ww  w. ja  v  a 2 s.c o  m
    if (List.class == returnType || Collection.class == returnType || Iterable.class == returnType) {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                return listResult;
            }

        };
    } else if (ArrayList.class == returnType) {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                return new ArrayList(listResult);
            }

        };
    } else if (LinkedList.class == returnType) {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                return new LinkedList(listResult);
            }

        };
    } else if (Set.class == returnType || HashSet.class == returnType) {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                return new HashSet(listResult);
            }

        };
    } else if (Collection.class.isAssignableFrom(returnType)) {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                Collection listToReturn;
                try {
                    listToReturn = (Collection) returnType.newInstance();
                } catch (Exception e) {
                    throw new Error("error to create instance of " + returnType.getName());
                }
                listToReturn.addAll(listResult);
                return listToReturn;
            }

        };
    } else if (Iterator.class == returnType) {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                return listResult.iterator();
            }

        };
    } else if (returnType.isArray() && byte[].class != returnType) {
        if (returnType.getComponentType().isPrimitive()) {
            converter = new ResultConverter() {

                @Override
                public Object convert(StatementRuntime runtime, List<?> listResult) {
                    Object array = Array.newInstance(returnType.getComponentType(), listResult.size());
                    int len = listResult.size();
                    for (int i = 0; i < len; i++) {
                        Array.set(array, i, listResult.get(i));
                    }
                    return array;
                }

            };
        } else {
            converter = new ResultConverter() {

                @Override
                public Object convert(StatementRuntime runtime, List<?> listResult) {
                    Object array = Array.newInstance(returnType.getComponentType(), listResult.size());
                    return listResult.toArray((Object[]) array);
                }

            };
        }

    } else if (Map.class == returnType || HashMap.class == returnType) {
        converter = new MapConverter() {
            @Override
            protected Map creatMap(StatementRuntime runtime) {
                return new HashMap();
            }
        };
    } else if (Hashtable.class == returnType) {
        converter = new MapConverter() {
            @Override
            protected Map creatMap(StatementRuntime runtime) {
                return new Hashtable();
            }
        };
    } else if (Map.class.isAssignableFrom(returnType)) {
        converter = new MapConverter() {
            @Override
            protected Map creatMap(StatementRuntime runtime) {
                try {
                    return (Map) returnType.newInstance();
                } catch (Exception e) {
                    throw new Error("error to create instance of " + returnType.getName());
                }
            }
        };
    }
    // 
    else {
        converter = new ResultConverter() {

            @Override
            public Object convert(StatementRuntime runtime, List<?> listResult) {
                final int sizeResult = listResult.size();
                if (sizeResult == 1) {
                    // ?  Bean?Boolean
                    return listResult.get(0);

                } else if (sizeResult == 0) {

                    // null
                    if (returnType.isPrimitive()) {
                        String msg = "Incorrect result size: expected 1, actual " + sizeResult + ": "
                                + runtime.getMetaData();
                        throw new EmptyResultDataAccessException(msg, 1);
                    } else {
                        return null;
                    }

                } else {
                    // IncorrectResultSizeDataAccessException
                    String msg = "Incorrect result size: expected 0 or 1, actual " + sizeResult + ": "
                            + runtime.getMetaData();
                    throw new IncorrectResultSizeDataAccessException(msg, 1, sizeResult);
                }
            }
        };
    }
    return converter;
}

From source file:org.openinfinity.core.async.ParallelServiceActivatorIntegrationTest.java

@Test
public void givenKnownCrudInterfacesWhenActivatingParellelServiceCallsThenCallBackResultsMustBeExpectedWithoutIdOnProperaccountWithCallbacks() {
    ParallelServiceActivator parallelServiceActivator = new ParallelServiceActivator();
    parallelServiceActivator.setExecutorServiceAdapter(executorServiceAdapter);

    String id = "testname";
    final Collection<Account> actualAccounts = new ArrayList<Account>();

    parallelServiceActivator.prepareToQueryAllById(integrationTestService, id)
            .prepareToQueryAllById(integrationTestService2, id).activate()
            .onResult(new AsyncResultCallback<Collection<Account>>() {
                @Override//ww  w .  j  av  a  2 s  .c  o  m
                public void onResult(Collection<Account> accounts) {
                    assertNotNull(accounts);
                    actualAccounts.addAll(accounts);
                }
            }).onResult(new AsyncResultCallback<Collection<Account>>() {
                @Override
                public void onResult(Collection<Account> accounts) {
                    assertNotNull(accounts);
                    actualAccounts.addAll(accounts);
                }
            });

    assertEquals(2, actualAccounts.size());
}

From source file:edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder.java

/**
 * Take the changed statements from the queue and determine which URIs that need to be updated in
 * the index.//from   w  w w.  j a va  2 s. c o  m
 */
private Collection<String> changedStatementsToUris() {
    //inform StatementToURIsToUpdate that index is starting
    for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) {
        stu.startIndexing();
    }

    Collection<String> urisToUpdate = new HashSet<String>();
    for (Statement stmt : getAndClearChangedStmts()) {
        for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) {
            urisToUpdate.addAll(stu.findAdditionalURIsToIndex(stmt));
        }
    }

    //inform StatementToURIsToUpdate that they are done
    for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) {
        stu.endIndxing();
    }

    return urisToUpdate;
}

From source file:edu.cornell.mannlib.vitro.webapp.sparql.GetClazzAllProperties.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (!isAuthorizedToDisplayPage(request, response, SimplePermission.USE_MISCELLANEOUS_PAGES.ACTION)) {
        return;/*from   w  w  w.j a va 2 s.c o m*/
    }

    VitroRequest vreq = new VitroRequest(request);

    String vClassURI = vreq.getParameter("vClassURI");
    if (vClassURI == null || vClassURI.trim().equals("")) {
        return;
    }

    Map<String, String> hm = new HashMap();

    // Get Data Properties
    // Add rdfs:label to the list
    hm.put("label", "http://www.w3.org/2000/01/rdf-schema#label0");
    /*
     * respo += "<option>" + "<key>" + "label" + "</key>" + "<value>" +
     * "http://www.w3.org/2000/01/rdf-schema#label" + "</value>" +
     * "<type>0</type>" + "</option>";
     */
    DataPropertyDao ddao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();

    Collection<DataProperty> dataProps = ddao.getDataPropertiesForVClass(vClassURI);
    Iterator<DataProperty> dataPropIt = dataProps.iterator();
    HashSet<String> dpropURIs = new HashSet<String>();
    while (dataPropIt.hasNext()) {
        DataProperty dp = dataPropIt.next();
        if (!(dpropURIs.contains(dp.getURI()))) {
            dpropURIs.add(dp.getURI());
            DataProperty dprop = (DataProperty) ddao.getDataPropertyByURI(dp.getURI());
            if (dprop != null) {
                if (dprop.getLocalName() != null || !dprop.getLocalName().equals("")) {
                    hm.put(dprop.getLocalName(), dprop.getURI() + "0");
                }
                /*
                 * respo += "<option>" + "<key>" + dprop.getLocalName() +
                 * "</key>" + "<value>" + dprop.getURI() + "</value>" +
                 * "<type>0</type>" + "</option>";
                 */
            }
        }
    }

    // Get Object Properties

    ObjectPropertyDao odao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
    PropertyInstanceDao piDao = vreq.getUnfilteredWebappDaoFactory().getPropertyInstanceDao();
    VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();

    // incomplete list of classes to check, but better than before
    List<String> superclassURIs = vcDao.getAllSuperClassURIs(vClassURI);
    superclassURIs.add(vClassURI);
    superclassURIs.addAll(vcDao.getEquivalentClassURIs(vClassURI));

    Map<String, PropertyInstance> propInstMap = new HashMap<String, PropertyInstance>();
    for (String classURI : superclassURIs) {
        Collection<PropertyInstance> propInsts = piDao.getAllPropInstByVClass(classURI);
        try {
            for (PropertyInstance propInst : propInsts) {
                propInstMap.put(propInst.getPropertyURI(), propInst);
            }
        } catch (NullPointerException ex) {
            continue;
        }
    }
    List<PropertyInstance> propInsts = new ArrayList<PropertyInstance>();
    propInsts.addAll(propInstMap.values());
    Collections.sort(propInsts);

    Iterator propInstIt = propInsts.iterator();
    HashSet opropURIs = new HashSet();
    while (propInstIt.hasNext()) {
        PropertyInstance pi = (PropertyInstance) propInstIt.next();
        if (!(opropURIs.contains(pi.getPropertyURI()))) {
            opropURIs.add(pi.getPropertyURI());
            ObjectProperty oprop = (ObjectProperty) odao.getObjectPropertyByURI(pi.getPropertyURI());
            if (oprop != null) {
                /*
                 * respo += "<option>" + "<key>" + oprop.getLocalName() +
                 * "</key>" + "<value>" + oprop.getURI() + "</value>" +
                 * "<type>1</type>" + "</option>";
                 */
                if (oprop.getLocalName() != null || !oprop.getLocalName().equals("")) {
                    hm.put(oprop.getLocalName(), oprop.getURI() + "1");
                }

            }
        }
    }
    String respo = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    respo += "<options>";
    Object[] keys = hm.keySet().toArray();
    Arrays.sort(keys);
    for (int i = 0; i < keys.length; i++) {
        String key = (String) keys[i];
        String value = hm.get(key);

        respo += "<option>" + "<key>" + key + "</key>" + "<value>" + value.substring(0, value.length() - 1)
                + "</value>" + "<type>" + value.charAt(value.length() - 1) + "</type>" + "</option>";
    }
    respo += "</options>";
    response.setContentType("text/xml");
    response.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();

    out.println(respo);
    out.flush();
    out.close();
}

From source file:oauth.signpost.signature.SignatureBaseString.java

/**
 * Collects x-www-form-urlencoded body parameters as per OAuth Core 1.0 spec
 * section 9.1.1//  ww  w .ja v a2  s  .  c  om
 */
private void collectBodyParameters(Collection<Parameter> parameters) throws IOException {

    // collect x-www-form-urlencoded body params
    if (request instanceof HttpEntityEnclosingRequest) {
        HttpEntityEnclosingRequest r = (HttpEntityEnclosingRequest) request;
        HttpEntity entity = r.getEntity();
        if (entity != null) {
            Header contentTypeHeader = entity.getContentType();
            if (contentTypeHeader != null && contentTypeHeader.getValue().equals(OAuth.FORM_ENCODED)) {
                parameters.addAll(OAuth.decodeForm(entity.getContent()));
            }
        }
    }
}

From source file:com.sfs.whichdoctor.analysis.FinancialSummaryAnalysisDAOImpl.java

/**
 * Gets the balance./*  w w  w  .  j a  v a  2 s  .  c  o m*/
 *
 * @param sqlWHERE the sql where
 * @param parameters the parameters
 * @param date the date
 * @param openingBalance the opening balance
 *
 * @return the balance
 */
private double getBalance(final String sqlWHERE, final Collection<Object> parameters, final Date date,
        final boolean openingBalance) {

    if (date == null && openingBalance) {
        return 0;
    }

    Collection<Object> balanceParameters = new ArrayList<Object>();
    balanceParameters.addAll(parameters);

    String sqlDate = "";
    if (date != null) {
        if (openingBalance) {
            sqlDate = " AND financial_summary.Issued < ?";
            String openingDate = df.format(date);
            balanceParameters.add(openingDate);
        } else {
            sqlDate = " AND financial_summary.Issued <= ?";
            String closingDate = df.format(date);
            balanceParameters.add(closingDate);
        }
    }

    double debits = 0;
    double credits = 0;
    double reimbursements = 0;
    double receipts = 0;

    /* Get sum of debits */
    try {
        dataLogger.debug("SQL WHERE: " + sqlWHERE);
        debits = this.queryForSubTotal(sqlWHERE, sqlDate, this.sqlDebitType, balanceParameters);
    } catch (Exception e) {
        dataLogger.error("Error getting debit sub-total: " + e.getMessage());
    }

    /* Get sum of receipts */
    try {
        receipts = this.queryForSubTotal(sqlWHERE, sqlDate, this.sqlReceiptType, balanceParameters);
    } catch (Exception e) {
        dataLogger.error("Error getting receipt sub-total: " + e.getMessage());
    }

    /* Get sum of credits */
    try {
        credits = this.queryForSubTotal(sqlWHERE, sqlDate, this.sqlCreditType, balanceParameters);
    } catch (Exception e) {
        dataLogger.error("Error getting credit sub-total: " + e.getMessage());
    }

    /* Get sum of reimbursements */
    try {
        reimbursements = this.queryForSubTotal(sqlWHERE, sqlDate, this.sqlReimbursementType, balanceParameters);
    } catch (Exception e) {
        dataLogger.error("Error getting reimbursement sub-total: " + e.getMessage());
    }

    dataLogger.debug("Debits total: " + debits);
    dataLogger.debug("Reimbursements total: " + reimbursements);
    dataLogger.debug("Receipts total: " + receipts);
    dataLogger.debug("Credits total: " + credits);

    return debits + reimbursements - receipts - credits;
}

From source file:com.fhc25.percepcion.osiris.mapviewer.data.indoor.impl.MapRepository.java

@Override
public ICancellableTask getMap(MongoGeospatialQuery query, String layer,
        IMongoGeospatialQueryParser mongoGeospatialQueryParser, final ICallback<Collection<Feature>> callback) {

    RequestConfiguration requestConfiguration = new RequestConfiguration(endpoint, endpoint.getMapService(),
            "POST");
    requestConfiguration.setQueryParams("&layer=" + layer);
    requestConfiguration.addHeader("Content-Type", "application/json");

    requestConfiguration.setBody(mongoGeospatialQueryParser.toJSON(query));

    final Collection<Feature> features = new ArrayList<>();

    return requestWithPagination(requestConfiguration, new PaginationCallback() {
        @Override/*from   w  ww.  j a v  a  2  s.c  o  m*/
        public boolean pageQueryReturned(String response) {

            Collection<FeatureDTO> receivedFeaturesDTO = parser.parseObjectCollection(response,
                    new TypeReference<Collection<FeatureDTO>>() {
                    });

            if (!receivedFeaturesDTO.isEmpty()) {
                Collection<Feature> receivedFeatures = assembler.createDomainObjects(receivedFeaturesDTO);
                features.addAll(receivedFeatures);
                return true;
            }

            return false;
        }

        @Override
        public void onFinish(Failure error, Void data) {
            callback.onFinish(error, features);
        }
    });
}

From source file:com.evolveum.midpoint.prism.delta.ContainerDelta.java

private Collection findItemValues(Long id, ItemPath path, Collection<PrismContainerValue<V>> cvalues) {
    if (cvalues == null) {
        return null;
    }//from  www . ja  v a2  s  .c o  m
    Collection<PrismValue> subValues = new ArrayList<>();
    for (PrismContainerValue<V> cvalue : cvalues) {
        if (id == null || id == cvalue.getId()) {
            Item<?, ?> item = cvalue.findItem(path);
            if (item != null) {
                subValues.addAll(PrismValue.cloneCollection(item.getValues()));
            }
        }
    }
    return subValues;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ListPropertyWebappsController.java

@Override
protected ResponseValues processRequest(VitroRequest vreq) {

    Map<String, Object> body = new HashMap<String, Object>();
    try {/*from  w  w w .  j av a  2  s.  c  o  m*/

        body.put("displayOption", "all");
        body.put("pageTitle", "All Object Properties");
        body.put("propertyType", "object");

        String noResultsMsgStr = "No object properties found";

        String ontologyUri = vreq.getParameter("ontologyUri");

        ObjectPropertyDao dao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
        ObjectPropertyDao opDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getObjectPropertyDao();
        PropertyInstanceDao piDao = vreq.getLanguageNeutralWebappDaoFactory().getPropertyInstanceDao();
        VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();
        VClassDao vcDaoLangNeut = vreq.getLanguageNeutralWebappDaoFactory().getVClassDao();
        PropertyGroupDao pgDao = vreq.getUnfilteredWebappDaoFactory().getPropertyGroupDao();

        String vclassURI = vreq.getParameter("vclassUri");

        List<ObjectProperty> props = new ArrayList<ObjectProperty>();
        if (vreq.getParameter("propsForClass") != null) {
            noResultsMsgStr = "There are no object properties that apply to this class.";

            // incomplete list of classes to check, but better than before
            List<String> superclassURIs = vcDao.getAllSuperClassURIs(vclassURI);
            superclassURIs.add(vclassURI);
            superclassURIs.addAll(vcDao.getEquivalentClassURIs(vclassURI));

            Map<String, PropertyInstance> propInstMap = new HashMap<String, PropertyInstance>();
            for (String classURI : superclassURIs) {
                Collection<PropertyInstance> propInsts = piDao.getAllPropInstByVClass(classURI);
                for (PropertyInstance propInst : propInsts) {
                    propInstMap.put(propInst.getPropertyURI(), propInst);
                }
            }
            List<PropertyInstance> propInsts = new ArrayList<PropertyInstance>();
            propInsts.addAll(propInstMap.values());
            Collections.sort(propInsts);

            Iterator<PropertyInstance> propInstIt = propInsts.iterator();
            HashSet<String> propURIs = new HashSet<String>();
            while (propInstIt.hasNext()) {
                PropertyInstance pi = (PropertyInstance) propInstIt.next();
                if (!(propURIs.contains(pi.getPropertyURI()))) {
                    propURIs.add(pi.getPropertyURI());
                    ObjectProperty prop = (ObjectProperty) dao.getObjectPropertyByURI(pi.getPropertyURI());
                    if (prop != null) {
                        props.add(prop);
                    }
                }
            }
        } else {
            props = (vreq.getParameter("iffRoot") != null) ? dao.getRootObjectProperties()
                    : dao.getAllObjectProperties();
        }

        OntologyDao oDao = vreq.getUnfilteredWebappDaoFactory().getOntologyDao();
        HashMap<String, String> ontologyHash = new HashMap<String, String>();

        Iterator<ObjectProperty> propIt = props.iterator();
        List<ObjectProperty> scratch = new ArrayList<ObjectProperty>();
        while (propIt.hasNext()) {
            ObjectProperty p = propIt.next();
            if (p.getNamespace() != null) {
                if (!ontologyHash.containsKey(p.getNamespace())) {
                    Ontology o = oDao.getOntologyByURI(p.getNamespace());
                    if (o == null) {
                        if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) {
                            log.debug(
                                    "doGet(): no ontology object found for the namespace " + p.getNamespace());
                        }
                    } else {
                        ontologyHash.put(p.getNamespace(),
                                o.getName() == null ? p.getNamespace() : o.getName());
                    }
                }
                if (ontologyUri != null && p.getNamespace().equals(ontologyUri)) {
                    scratch.add(p);
                }
            }
        }

        if (ontologyUri != null) {
            props = scratch;
        }

        if (props != null) {
            sortForPickList(props, vreq);
        }

        String json = new String();
        int counter = 0;

        if (props != null) {
            if (props.size() == 0) {
                json = "{ \"name\": \"" + noResultsMsgStr + "\" }";
            } else {
                Iterator<ObjectProperty> propsIt = props.iterator();
                while (propsIt.hasNext()) {
                    if (counter > 0) {
                        json += ", ";
                    }
                    ObjectProperty prop = propsIt.next();

                    String propNameStr = ShowObjectPropertyHierarchyController.getDisplayLabel(prop);

                    try {
                        json += "{ \"name\": "
                                + JSONUtils.quote("<a href='./propertyEdit?uri="
                                        + URLEncoder.encode(prop.getURI()) + "'>" + propNameStr + "</a>")
                                + ", ";
                    } catch (Exception e) {
                        json += "{ \"name\": \"" + propNameStr + "\", ";
                    }

                    json += "\"data\": { \"internalName\": " + JSONUtils.quote(prop.getLocalNameWithPrefix())
                            + ", ";

                    ObjectProperty opLangNeut = opDaoLangNeut.getObjectPropertyByURI(prop.getURI());
                    if (opLangNeut == null) {
                        opLangNeut = prop;
                    }
                    String domainStr = getVClassNameFromURI(opLangNeut.getDomainVClassURI(), vcDao,
                            vcDaoLangNeut);
                    json += "\"domainVClass\": " + JSONUtils.quote(domainStr) + ", ";

                    String rangeStr = getVClassNameFromURI(opLangNeut.getRangeVClassURI(), vcDao,
                            vcDaoLangNeut);
                    json += "\"rangeVClass\": " + JSONUtils.quote(rangeStr) + ", ";

                    if (prop.getGroupURI() != null) {
                        PropertyGroup pGroup = pgDao.getGroupByURI(prop.getGroupURI());
                        json += "\"group\": "
                                + JSONUtils.quote((pGroup == null) ? "unknown group" : pGroup.getName())
                                + " } } ";
                    } else {
                        json += "\"group\": \"unspecified\" } }";
                    }
                    counter += 1;
                }
            }
            body.put("jsonTree", json);
        }

    } catch (Throwable t) {
        t.printStackTrace();
    }

    return new TemplateResponseValues(TEMPLATE_NAME, body);
}