Search in sources :

Example 1 with LegacyUnit

use of eu.ggnet.dwoss.redtape.ee.api.LegacyUnit in project dwoss by gg-net.

the class UniversalSearcherOperation method searchUnits.

/**
 * Returns a List of short descriptions of Units in Html.
 * Ensure to add the html start/end tags manually
 * <p/>
 * @param search a search string.
 * @return a List of short descriptions of Units in Html.
 */
// Used in Misc. Unversal Search
@Override
public List<Tuple2<Long, String>> searchUnits(String search) {
    List<UniqueUnit> uus = new UniqueUnitEao(uuEm).find(search);
    List<Tuple2<Long, String>> result = new ArrayList<>(uus.size());
    Set<Long> uurefurbishIds = new HashSet<>();
    for (UniqueUnit uu : uus) {
        // TODO: WARNING, if we start using letters in refurbhisIds, the search will not show any results.
        try {
            long sopoNr = Long.parseLong(uu.getRefurbishId());
            uurefurbishIds.add(sopoNr);
            result.add(new Tuple2(sopoNr, UniqueUnitFormater.toSimpleHtml(uu)));
        } catch (NumberFormatException e) {
            continue;
        }
    }
    if (bridgeInstance.isUnsatisfied())
        return result;
    for (LegacyUnit unit : bridgeInstance.get().findUnit(search)) {
        try {
            if (uurefurbishIds.contains(Long.parseLong(unit.getUnitIdentifier())))
                continue;
            String re = "<b>" + unit.getUnitIdentifier() + "</b> - ";
            re += unit.getSerial() + "<br />";
            re += unit.getManufacturerPartNo() + "<br />";
            re += "Status: <i>Nicht verfügbar (Legacy System:" + bridgeInstance.get().localName() + ")</i><br />";
            result.add(new Tuple2<>(Long.parseLong(unit.getUnitIdentifier()), re));
        } catch (NumberFormatException e) {
        // Ignore
        }
    }
    return result;
}
Also used : LegacyUnit(eu.ggnet.dwoss.redtape.ee.api.LegacyUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) Tuple2(eu.ggnet.dwoss.util.Tuple2)

Aggregations

LegacyUnit (eu.ggnet.dwoss.redtape.ee.api.LegacyUnit)1 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)1 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)1 Tuple2 (eu.ggnet.dwoss.util.Tuple2)1