ingo@2191: package de.intevation.flys.artifacts.states;
ingo@2191:
ingo@2191: import java.util.List;
ingo@2191:
ingo@2191: import org.apache.log4j.Logger;
ingo@2191:
ingo@2191: import org.w3c.dom.Element;
ingo@2191:
ingo@2191: import de.intevation.artifacts.Artifact;
ingo@2191: import de.intevation.artifacts.CallContext;
ingo@2191: import de.intevation.artifacts.CallMeta;
ingo@2191:
ingo@2191: import de.intevation.artifacts.common.utils.XMLUtils;
ingo@2191:
ingo@2191: import de.intevation.flys.model.Gauge;
ingo@2191: import de.intevation.flys.model.River;
ingo@2191:
ingo@2191: import de.intevation.flys.artifacts.FLYSArtifact;
ingo@2191: import de.intevation.flys.utils.FLYSUtils;
ingo@2191:
ingo@2191:
ingo@2191: /**
ingo@2191: * @author Ingo Weinzierl
ingo@2191: */
ingo@2191: public class ReferenceGaugeState extends DefaultState {
ingo@2191:
ingo@2191: private static final Logger logger =
ingo@2191: Logger.getLogger(ReferenceGaugeState.class);
ingo@2191:
ingo@2191:
ingo@2191: @Override
ingo@2191: protected Element[] createItems(
ingo@2191: XMLUtils.ElementCreator cr,
ingo@2191: Artifact artifact,
ingo@2191: String name,
ingo@2191: CallContext context)
ingo@2191: {
ingo@2191: CallMeta meta = context.getMeta();
ingo@2191:
ingo@2191: River river = FLYSUtils.getRiver((FLYSArtifact) artifact);
ingo@2191: List gauges = river.getGauges();
ingo@2191:
ingo@2191: int num = gauges != null ? gauges.size() : 0;
ingo@2191:
ingo@2191: Element[] opts = new Element[num];
ingo@2191:
ingo@2191: for (int i = 0; i < num; i++ ) {
ingo@2191: Gauge g = gauges.get(i);
ingo@2191:
ingo@2191: String gaugeName = g.getName();
ingo@2191: long officialNumber = g.getOfficialNumber();
ingo@2191:
ingo@2191: opts[i] = createItem(
ingo@2191: cr, new String[] { gaugeName, String.valueOf(officialNumber) });
ingo@2191: }
ingo@2191:
ingo@2191: return opts;
ingo@2191: }
ingo@2191: }
ingo@2191: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :