raimund@691: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@691: * Software engineering by Intevation GmbH raimund@691: * raimund@691: * This file is Free Software under the GNU GPL (v>=3) raimund@691: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@691: * the documentation coming with IMIS-Labordaten-Application for details. raimund@691: */ raimund@656: package de.intevation.lada.factory; raimund@656: raimund@656: import java.sql.Timestamp; raimund@656: import java.util.ArrayList; raimund@656: import java.util.Calendar; raimund@656: import java.util.Date; raimund@656: import java.util.List; tom@1064: import java.util.Hashtable; raimund@656: raimund@656: import javax.inject.Inject; raimund@656: raimund@981: import org.apache.log4j.Logger; raimund@981: tom@1097: import de.intevation.lada.model.land.KommentarP; raimund@656: import de.intevation.lada.model.land.Messprogramm; raimund@656: import de.intevation.lada.model.land.MessprogrammMmt; tom@1097: import de.intevation.lada.model.land.Probe; tom@1097: import de.intevation.lada.model.land.Messung; tom@1097: import de.intevation.lada.model.land.Messwert; tom@1097: import de.intevation.lada.model.land.Ortszuordnung; raimund@1262: import de.intevation.lada.model.land.OrtszuordnungMp; tom@1097: import de.intevation.lada.model.land.StatusProtokoll; tom@1097: import de.intevation.lada.model.stammdaten.DeskriptorUmwelt; tom@1097: import de.intevation.lada.model.stammdaten.Deskriptoren; tom@1097: import de.intevation.lada.model.stammdaten.Ort; raimund@656: import de.intevation.lada.util.annotation.RepositoryConfig; raimund@656: import de.intevation.lada.util.data.QueryBuilder; raimund@656: import de.intevation.lada.util.data.Repository; raimund@656: import de.intevation.lada.util.data.RepositoryType; raimund@656: import de.intevation.lada.util.rest.Response; raimund@656: raimund@691: /** raimund@691: * This factory creates probe objects and its children using a messprogramm raimund@691: * as template. raimund@691: * raimund@691: * @author Raimund Renkert raimund@691: */ raimund@656: public class ProbeFactory { raimund@656: tom@1083: // Day of year representing February 28 tom@1083: private static final int FEBRUARY_28 = 58; tom@1083: tom@1064: private static Hashtable fieldsTable; tom@1064: tom@1064: public ProbeFactory() { tom@1079: int[] T = { Calendar.DAY_OF_YEAR, Calendar.DAY_OF_YEAR, 1 }; tom@1079: int[] W = { Calendar.DAY_OF_YEAR, Calendar.DAY_OF_YEAR, 7 }; tom@1079: int[] W2 = { Calendar.DAY_OF_YEAR, Calendar.DAY_OF_YEAR, 14 }; tom@1079: int[] W4 = { Calendar.DAY_OF_YEAR, Calendar.DAY_OF_YEAR, 28 }; tom@1075: tom@1064: int[] M = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 1 }; tom@1064: int[] Q = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 3 }; tom@1064: int[] H = { Calendar.MONTH, Calendar.DAY_OF_MONTH, 6 }; tom@1064: tom@1083: int[] J = { Calendar.YEAR, Calendar.DAY_OF_YEAR, 1 }; tom@1083: raimund@1262: fieldsTable = new Hashtable(); tom@1064: raimund@1262: fieldsTable.put("T", T); raimund@1262: fieldsTable.put("W", W); raimund@1262: fieldsTable.put("W2", W2); raimund@1262: fieldsTable.put("W4", W4); raimund@1262: fieldsTable.put("M", M); raimund@1262: fieldsTable.put("Q", Q); raimund@1262: fieldsTable.put("H", H); raimund@1262: fieldsTable.put("J", J); tom@1064: } tom@1064: tom@1064: private class Intervall { tom@1079: private final int teilVon; tom@1079: private final int teilBis; tom@1079: private final int offset; tom@1064: tom@1079: private final int intervallField; tom@1079: private final int subIntField; tom@1079: private final int intervallFactor; tom@1064: tom@1064: private Calendar from; tom@1064: tom@1064: public Intervall( tom@1064: Messprogramm messprogramm, tom@1064: Calendar start tom@1064: ) { tom@1064: this.teilVon = messprogramm.getTeilintervallVon(); tom@1064: this.teilBis = messprogramm.getTeilintervallBis(); tom@1064: this.offset = messprogramm.getIntervallOffset(); tom@1064: tom@1064: this.intervallField = fieldsTable tom@1064: .get(messprogramm.getProbenintervall())[0]; tom@1064: this.subIntField = fieldsTable tom@1064: .get(messprogramm.getProbenintervall())[1]; tom@1064: this.intervallFactor = fieldsTable tom@1064: .get(messprogramm.getProbenintervall())[2]; tom@1064: tom@1064: this.from = (Calendar)start.clone(); tom@1079: tom@1079: /* Align with beginning of next interval tom@1079: * like first day of next quarter or Monday of next week.*/ tom@1079: if (intervallField == Calendar.DAY_OF_YEAR tom@1079: && intervallFactor % 7 == 0 tom@1079: ) { tom@1079: if (from.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { tom@1079: from.add(Calendar.WEEK_OF_YEAR, 1); tom@1079: from.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); tom@1079: } tom@1079: } else { tom@1079: int startIntField = start.get(intervallField); tom@1079: from.set( tom@1079: intervallField, tom@1079: startIntField + startIntField % intervallFactor tom@1079: ); tom@1079: } tom@1064: from = adjustSubIntField(from, teilVon); tom@1064: if (start.after(from)) { tom@1064: // to next intervall if start not at first day of intervall tom@1064: this.roll(); tom@1064: } tom@1064: } tom@1064: tom@1064: /** tom@1064: * Return given calendar adjusted to start of intervall (e.g. first tom@1064: * day in quarter) plus offset and given amount of days. tom@1064: * tom@1064: * @param cal Calendar to be adjusted tom@1064: * @param int amount of days to be added (plus offset) tom@1064: * tom@1064: * @return the adjusted Calendar object. tom@1064: */ tom@1064: private Calendar adjustSubIntField(Calendar cal, int teil) { tom@1075: int intValue = cal.get(intervallField); tom@1079: int adjust = offset; tom@1075: tom@1079: if (intervallField != subIntField) { tom@1079: intValue = intValue - intValue % intervallFactor; tom@1079: cal.set(intervallField, intValue); tom@1083: tom@1083: if (subIntField == Calendar.DAY_OF_YEAR) { tom@1083: // Adjust in leap year tom@1083: teil += startInLeapYear() && teil > FEBRUARY_28 tom@1083: ? 1 tom@1083: : 0; tom@1083: } tom@1079: } else { tom@1079: adjust += intValue - 1; tom@1079: } tom@1079: tom@1079: int subIntValue = adjust + Math.min(teil, getDuration()); tom@1075: cal.set(subIntField, subIntValue); tom@1075: tom@1064: return cal; tom@1064: } tom@1064: tom@1064: /** tom@1075: * @return sum of actual maxima for subIntField from beginning of tom@1075: * actual intervall for the next intervallFactor values intervallField tom@1075: * or just intervallFactor, if subIntField == intervallField. tom@1064: */ tom@1064: private int getDuration() { tom@1075: if (subIntField == intervallField) { tom@1075: return intervallFactor; tom@1075: } tom@1064: int duration = 0; tom@1064: Calendar tmp = (Calendar)from.clone(); tom@1083: tom@1064: /* reset to beginning of intervall, e.g. first day of quarter tom@1064: * to compensate possible overflow if tom@1064: * teilVon > maximum of intervallField: */ tom@1075: int intValue = from.get(intervallField); tom@1064: tmp.set( tom@1064: intervallField, tom@1075: intValue - intValue % intervallFactor tom@1064: ); tom@1064: tmp.set(subIntField, tmp.getActualMinimum(subIntField)); tom@1083: tom@1064: for (int i = 0; i < intervallFactor; i++) { tom@1064: duration += tmp.getActualMaximum(subIntField); tom@1064: tmp.add(intervallField, 1); tom@1064: } tom@1064: return duration; tom@1064: } tom@1064: tom@1064: public Date getFrom() { tom@1064: return from.getTime(); tom@1064: } tom@1064: tom@1064: public Date getTo() { tom@1064: Calendar to = (Calendar)from.clone(); tom@1064: to = adjustSubIntField(to, teilBis); tom@1064: return to.getTime(); tom@1064: } tom@1064: tom@1064: public boolean startInLeapYear() { tom@1077: return from.getActualMaximum(Calendar.DAY_OF_YEAR) > 365; tom@1064: } tom@1064: tom@1064: public int getStartDOY() { tom@1064: return from.get(Calendar.DAY_OF_YEAR); tom@1064: } tom@1064: tom@1064: public void roll() { tom@1064: from.add(intervallField, intervallFactor); tom@1064: from = adjustSubIntField(from, teilVon); tom@1064: } tom@1064: tom@1064: } tom@1064: // end Intervall class tom@1064: tom@1064: raimund@981: @Inject Logger logger; raimund@981: raimund@691: /** raimund@691: * The data repository raimund@691: */ raimund@656: @Inject raimund@656: @RepositoryConfig(type = RepositoryType.RW) raimund@656: private Repository repository; raimund@656: raimund@691: /** raimund@691: * Create a list of probe objects raimund@691: * raimund@691: * @param id Messprogramm id raimund@691: * @param from The start date raimund@691: * @param to The end date raimund@691: * raimund@691: * @return List of probe objects. raimund@691: */ tom@1097: public List create(Messprogramm messprogramm, Long from, Long to) { raimund@656: Calendar start = Calendar.getInstance(); tom@1061: start.setTimeInMillis(from); tom@1074: raimund@656: Calendar end = Calendar.getInstance(); tom@1061: end.setTimeInMillis(to); tom@1074: /* Adjust to end of the day as we want to generate Probe objects tom@1074: * before or at this day. */ tom@1074: end.set(Calendar.HOUR_OF_DAY, 23); tom@1074: end.set(Calendar.MINUTE, 59); tom@1074: end.set(Calendar.SECOND, 59); tom@1064: tom@1062: int gueltigVon = messprogramm.getGueltigVon(); tom@1062: int gueltigBis = messprogramm.getGueltigBis(); tom@1062: tom@1097: List proben = new ArrayList(); raimund@981: tom@1064: for (Intervall intervall = new Intervall(messprogramm, start); tom@1064: intervall.getFrom().before(end.getTime()); tom@1064: intervall.roll() tom@1064: ) { tom@1062: /* Leap year adaption of validity period. tom@1062: * It is assumed here (and should be enforced by the data model) tom@1062: * that gueltigVon and gueltigBis are always given relative to tom@1062: * a non-leap year. E.g. a value of 59 is assumed to denote tom@1062: * March 1 and thus has to be adapted in a leap year. */ tom@1064: int leapDay = intervall.startInLeapYear() ? 1 : 0; tom@1062: int actualGueltigVon = tom@1083: gueltigVon > FEBRUARY_28 tom@1062: ? gueltigVon + leapDay tom@1062: : gueltigVon; tom@1062: int actualGueltigBis = tom@1083: gueltigBis > FEBRUARY_28 tom@1062: ? gueltigBis + leapDay tom@1062: : gueltigBis; tom@1062: tom@1064: int solldatumBeginnDOY = intervall.getStartDOY(); tom@1062: tom@1062: if (( tom@1062: // Validity within one year tom@1062: actualGueltigVon < actualGueltigBis tom@1062: && solldatumBeginnDOY >= actualGueltigVon tom@1062: && solldatumBeginnDOY <= actualGueltigBis tom@1062: ) || ( tom@1062: // Validity over turn of the year tom@1062: actualGueltigVon > actualGueltigBis tom@1062: && (solldatumBeginnDOY >= actualGueltigVon tom@1062: || solldatumBeginnDOY <= actualGueltigBis) tom@1062: ) tom@1062: ) { tom@1097: Probe probe = createObjects( tom@1062: messprogramm, tom@1064: intervall.getFrom(), tom@1064: intervall.getTo() tom@1062: ); raimund@981: if (probe != null) { raimund@981: proben.add(probe); raimund@981: } raimund@981: } raimund@981: } raimund@981: raimund@981: return proben; raimund@981: } raimund@981: raimund@711: /** raimund@711: * Create a single probe object. raimund@711: * raimund@711: * @param messprogramm The messprogramm containing probe details raimund@711: * @param startDate The date for 'solldatumbeginn' raimund@711: * @param endDate The date for 'solldatumende' raimund@711: * raimund@711: * @return The new probe object. raimund@711: */ tom@1097: private Probe createObjects( raimund@656: Messprogramm messprogramm, raimund@656: Date startDate, raimund@656: Date endDate raimund@656: ) { tom@1097: QueryBuilder builderProbe = tom@1097: new QueryBuilder( raimund@981: repository.entityManager("land"), tom@1097: Probe.class); raimund@981: builderProbe.and("mprId", messprogramm.getId()); raimund@981: builderProbe.and("solldatumBeginn", startDate); raimund@981: builderProbe.and("solldatumEnde", endDate); raimund@981: tom@1097: List proben = raimund@981: repository.filterPlain(builderProbe.getQuery(), "land"); raimund@981: raimund@981: if (!proben.isEmpty()) { raimund@981: return null; raimund@981: } tom@1097: Probe probe = new Probe(); raimund@656: probe.setBaId(messprogramm.getBaId()); raimund@656: probe.setDatenbasisId(messprogramm.getDatenbasisId()); raimund@656: probe.setMediaDesk(messprogramm.getMediaDesk()); raimund@656: probe.setMstId(messprogramm.getMstId()); raimund@896: probe.setLaborMstId(messprogramm.getLaborMstId()); raimund@656: probe.setProbenartId(messprogramm.getProbenartId()); raimund@656: probe.setProbeNehmerId(messprogramm.getProbeNehmerId()); raimund@656: probe.setSolldatumBeginn(new Timestamp(startDate.getTime())); raimund@656: probe.setSolldatumEnde(new Timestamp(endDate.getTime())); raimund@656: probe.setTest(messprogramm.getTest()); raimund@656: probe.setUmwId(messprogramm.getUmwId()); raimund@981: probe.setMprId(messprogramm.getId()); raimund@656: repository.create(probe, "land"); raimund@656: raimund@656: if (messprogramm.getProbeKommentar() != null && raimund@656: !messprogramm.getProbeKommentar().equals("")) { tom@1097: KommentarP kommentar = new KommentarP(); raimund@656: kommentar.setDatum(new Timestamp(new Date().getTime())); raimund@656: kommentar.setProbeId(probe.getId()); raimund@656: kommentar.setText(messprogramm.getProbeKommentar()); tom@1097: kommentar.setMstId(messprogramm.getMstId()); raimund@656: raimund@656: repository.create(kommentar, "land"); raimund@656: } raimund@656: raimund@656: QueryBuilder builder = raimund@656: new QueryBuilder( raimund@656: repository.entityManager("land"), raimund@656: MessprogrammMmt.class); raimund@656: builder.and("messprogrammId", messprogramm.getId()); raimund@656: Response response = repository.filter(builder.getQuery(), "land"); raimund@685: @SuppressWarnings("unchecked") raimund@656: List mmts = (List)response.getData(); raimund@1262: for (int i = 0; i < mmts.size(); i++) { raimund@1262: MessprogrammMmt mmt = mmts.get(i); tom@1097: Messung messung = new Messung(); raimund@656: messung.setFertig(false); raimund@656: messung.setGeplant(true); raimund@656: messung.setMmtId(mmt.getMmtId()); raimund@656: messung.setNebenprobenNr( tom@1097: messprogramm.getMstId() + mmt.getMmtId()); raimund@656: messung.setProbeId(probe.getId()); raimund@656: repository.create(messung, "land"); raimund@897: raimund@656: for (int mw : mmt.getMessgroessen()) { tom@1097: Messwert wert = new Messwert(); raimund@656: wert.setMessgroesseId(mw); raimund@656: wert.setMessungsId(messung.getId()); tom@914: wert.setMesswert(0d); raimund@656: wert.setMehId(1); raimund@656: repository.create(wert, "land"); raimund@656: } raimund@656: } raimund@1262: QueryBuilder builderOrt = raimund@1262: new QueryBuilder( raimund@1262: repository.entityManager("land"), raimund@1262: OrtszuordnungMp.class); raimund@1324: builderOrt.and("messprogrammId", messprogramm.getId()); raimund@1262: List orte = raimund@1262: repository.filterPlain(builderOrt.getQuery(), "land"); raimund@1262: for (OrtszuordnungMp ort : orte) { raimund@1262: Ortszuordnung ortP = new Ortszuordnung(); raimund@1262: ortP.setOrtszuordnungTyp(ort.getOrtszuordnungTyp()); raimund@1262: ortP.setProbeId(probe.getId()); raimund@1262: ortP.setOrtId(ort.getOrtId()); raimund@1262: ortP.setOrtszusatztext(ort.getOrtszusatztext()); raimund@1262: repository.create(ortP, "land"); raimund@656: } raimund@680: // Reolad the probe to have the old id tom@1097: probe = (Probe)repository.getById( tom@1097: Probe.class, probe.getId(), "land").getData(); raimund@656: return probe; raimund@656: } raimund@656: raimund@711: /** raimund@711: * Search for the umwelt id using the 'deskriptor'. raimund@711: * raimund@711: * @param probe The probe object. raimund@711: * raimund@711: * @return The updated probe object. raimund@711: */ tom@1097: public Probe findUmweltId(Probe probe) { tom@1122: String mediaDesk = probe.getMediaDesk(); tom@1122: if (mediaDesk != null) { tom@1122: String[] mediaDeskParts = mediaDesk.split(" "); tom@1122: if (mediaDeskParts.length <= 1) { tom@1122: return probe; tom@1122: } tom@1122: probe.setUmwId(findUmwelt(mediaDeskParts)); raimund@695: } raimund@697: return probe; raimund@697: } raimund@711: raimund@711: /** raimund@711: * Search for the media description using the 'deskriptor'. raimund@711: * raimund@711: * @param probe The probe object raimund@711: * raimund@711: * @return The updated probe object. raimund@711: */ tom@1097: public Probe findMediaDesk(Probe probe) { tom@1122: String mediaDesk = probe.getMediaDesk(); tom@1122: if (mediaDesk != null) { tom@1122: Object result = repository.queryFromString( raimund@713: "SELECT get_media_from_media_desk( :mediaDesk );", "stamm") tom@1122: .setParameter("mediaDesk", mediaDesk) tom@1122: .getSingleResult(); tom@1122: probe.setMedia(result != null ? result.toString() : ""); tom@1122: } mlechner@709: return probe; mlechner@709: } raimund@697: raimund@711: /** raimund@711: * Search for the umwelt id using the 'deskriptor'. raimund@711: * raimund@711: * @param messprogramm The messprogramm raimund@711: * raimund@711: * @return The updated messprogramm. raimund@711: */ raimund@697: public Messprogramm findUmweltId(Messprogramm messprogramm) { tom@1122: String mediaDesk = messprogramm.getMediaDesk(); tom@1122: if (mediaDesk != null) { tom@1122: String[] mediaDeskParts = mediaDesk.split(" "); tom@1122: if (mediaDeskParts.length <= 1) { tom@1122: return messprogramm; tom@1122: } tom@1122: messprogramm.setUmwId(findUmwelt(mediaDeskParts)); raimund@697: } raimund@697: return messprogramm; raimund@697: } raimund@697: tom@1064: raimund@711: /** raimund@711: * Find the umwelt id for a given deskriptor. raimund@711: * raimund@711: * @param mediaDesk The deskriptor string raimund@711: * raimund@711: * @return The umwelt id or an empty string. raimund@711: */ raimund@697: private String findUmwelt(String[] mediaDesk) { raimund@695: List mediaIds = new ArrayList(); raimund@695: boolean zebs = false; raimund@695: Integer parent = null; raimund@695: Integer hdParent = null; raimund@695: Integer ndParent = null; raimund@695: if ("01".equals(mediaDesk[1])) { raimund@695: zebs = true; raimund@695: } raimund@695: for (int i = 1; i < mediaDesk.length; i++) { raimund@695: if ("00".equals(mediaDesk[i])) { raimund@695: mediaIds.add(-1); raimund@695: continue; raimund@695: } raimund@695: if (zebs && i < 5) { raimund@695: parent = hdParent; raimund@695: } raimund@695: else if (!zebs && i < 3) { raimund@695: parent = hdParent; raimund@695: } raimund@695: else { raimund@695: parent = ndParent; raimund@695: } raimund@695: QueryBuilder builder = new QueryBuilder( raimund@695: repository.entityManager("stamm"), Deskriptoren.class); raimund@695: if (parent != null) { raimund@695: builder.and("vorgaenger", parent); raimund@695: } raimund@695: builder.and("sn", mediaDesk[i]); raimund@695: builder.and("ebene", i - 1); raimund@695: Response response = repository.filter(builder.getQuery(), "stamm"); raimund@695: @SuppressWarnings("unchecked") raimund@695: List data = (List)response.getData(); raimund@695: if (data.isEmpty()) { raimund@697: return ""; raimund@695: } raimund@695: hdParent = data.get(0).getId(); raimund@695: mediaIds.add(data.get(0).getId()); raimund@695: if (i == 2) { raimund@695: ndParent = data.get(0).getId(); raimund@695: } raimund@695: } raimund@697: return getUmwelt(mediaIds, zebs); raimund@695: } raimund@695: raimund@711: /** raimund@711: * Find the umwelt id in the database using media deskriptor ids. raimund@711: * raimund@711: * @param media The list of media ids. raimund@711: * @param isZebs Flag for type of the deskriptor. raimund@711: * raimund@711: * @return The umwelt id or an empty string. raimund@711: */ raimund@697: private String getUmwelt(List media, boolean isZebs) { raimund@695: QueryBuilder builder = raimund@695: new QueryBuilder( raimund@695: repository.entityManager("stamm"), DeskriptorUmwelt.class); raimund@695: raimund@695: if (media.size() == 0) { raimund@697: return ""; raimund@695: } raimund@695: raimund@735: int size = 1; raimund@695: for (int i = size; i >= 0; i--) { raimund@695: if (media.get(i) == -1) { raimund@695: continue; raimund@695: } raimund@695: String field = "s" + (i > 9 ? i : "0" + i); raimund@695: builder.and(field, media.get(i)); raimund@695: } raimund@695: Response response = repository.filter(builder.getQuery(), "stamm"); raimund@695: @SuppressWarnings("unchecked") raimund@695: List data = (List)response.getData(); raimund@695: if (data.isEmpty()) { raimund@732: return null; raimund@695: } raimund@695: raimund@695: boolean unique = isUnique(data); raimund@695: if (unique) { raimund@697: return data.get(0).getUmwId(); raimund@695: } raimund@695: else { raimund@696: int found = -1; raimund@695: for (int i = 0; i < data.size(); i++) { raimund@696: int matches = 0; raimund@696: int lastMatch = 0; raimund@696: for (int j = size + 1; j < 12; j++) { raimund@695: switch(j) { raimund@696: case 2: if (media.get(2).equals(data.get(i).getS02())) raimund@696: matches += 1; raimund@695: break; raimund@696: case 3: if (media.get(3).equals(data.get(i).getS03())) raimund@696: matches += 1; raimund@695: break; raimund@696: case 4: if (media.get(4).equals(data.get(i).getS04())) raimund@696: matches += 1; raimund@695: break; raimund@696: case 5: if (media.get(5).equals(data.get(i).getS05())) raimund@696: matches +=1; raimund@695: break; raimund@696: case 6: if (media.get(6).equals(data.get(i).getS06())) raimund@696: matches += 1; raimund@695: break; raimund@696: case 7: if (media.get(7).equals(data.get(i).getS07())) raimund@696: matches += 1; raimund@696: break; raimund@696: case 8: if (media.get(8).equals(data.get(i).getS08())) raimund@696: matches += 1; raimund@696: break; raimund@696: case 9: if (media.get(9).equals(data.get(i).getS09())) raimund@696: matches += 1; raimund@696: break; raimund@696: case 10: if (media.get(10).equals(data.get(i).getS10())) raimund@696: matches += 1; raimund@696: break; raimund@696: case 11: if (media.get(11).equals(data.get(i).getS11())) raimund@696: matches += 1; raimund@696: break; raimund@695: } raimund@696: if (matches > lastMatch) { raimund@696: lastMatch = matches; raimund@696: found = i; raimund@695: } raimund@695: } raimund@696: if (found >= 0) { raimund@697: return data.get(found).getUmwId(); raimund@696: } raimund@695: } raimund@732: return null; raimund@695: } raimund@695: } raimund@695: raimund@711: /** raimund@711: * Determine if the entries in the list have the same umwelt id. raimund@711: * raimund@711: * @param list A list of DescriptorUmwelt objects. raimund@711: * raimund@711: * @return true if the objects have the same umwelt id else false. raimund@711: */ raimund@695: private boolean isUnique(List list) { raimund@695: if (list.isEmpty()) { raimund@695: return false; raimund@695: } raimund@695: String element = list.get(0).getUmwId(); raimund@695: for (int i = 1; i < list.size(); i++) { raimund@695: if (!element.equals(list.get(i))) { raimund@695: return false; raimund@695: } raimund@695: } raimund@695: return true; raimund@695: } raimund@695: raimund@656: }