comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 3553:5da58c5c1517

FLYSArtifact: Some code simplifications. flys-artifacts/trunk@5147 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 28 Jul 2012 20:38:27 +0000
parents 0d63581c5df1
children 9b356ed24411
comparison
equal deleted inserted replaced
3552:1df6984628c3 3553:5da58c5c1517
381 381
382 Element result = creator.create("result"); 382 Element result = creator.create("result");
383 doc.appendChild(result); 383 doc.appendChild(result);
384 384
385 try { 385 try {
386 saveData(target, XPATH_FEED_INPUT, context); 386 saveData(target, context);
387 387
388 compute(context, ComputeType.FEED, true); 388 compute(context, ComputeType.FEED, true);
389 389
390 return describe(target, context); 390 return describe(target, context);
391 } 391 }
848 848
849 849
850 public List<Facet> getFacets() { 850 public List<Facet> getFacets() {
851 List<Facet> all = new ArrayList<Facet>(); 851 List<Facet> all = new ArrayList<Facet>();
852 852
853 Set<Map.Entry<String, List<Facet>>> entries = facets.entrySet(); 853 for (List<Facet> fs: facets.values()) {
854 for (Map.Entry<String, List<Facet>> entry: entries) { 854 all.addAll(fs);
855 List<Facet> fs = entry.getValue();
856 for (Facet f: fs) {
857 all.add(f);
858 }
859 } 855 }
860 856
861 return all; 857 return all;
862 } 858 }
863 859
870 */ 866 */
871 public Facet getNativeFacet(Facet facet) { 867 public Facet getNativeFacet(Facet facet) {
872 String name = facet.getName(); 868 String name = facet.getName();
873 int index = facet.getIndex(); 869 int index = facet.getIndex();
874 870
875 for (Map.Entry<String, List<Facet>> facetList: facets.entrySet()) { 871 for (List<Facet> fs: facets.values()) {
876 for (Facet f: facetList.getValue()) { 872 for (Facet f: fs) {
877 if (f.getIndex() == index && f.getName().equals(name)) { 873 if (f.getIndex() == index && f.getName().equals(name)) {
878 return f; 874 return f;
879 } 875 }
880 } 876 }
881 } 877 }
889 * This method stores the data that is contained in the FEED document. 885 * This method stores the data that is contained in the FEED document.
890 * 886 *
891 * @param feed The FEED document. 887 * @param feed The FEED document.
892 * @param xpath The XPath that points to the data nodes. 888 * @param xpath The XPath that points to the data nodes.
893 */ 889 */
894 public void saveData(Document feed, String xpath, CallContext context) 890 public void saveData(Document feed, CallContext context)
895 throws IllegalArgumentException 891 throws IllegalArgumentException
896 { 892 {
897 if (feed == null || xpath == null || xpath.length() == 0) { 893 if (feed == null) {
898 throw new IllegalArgumentException("error_feed_no_data"); 894 throw new IllegalArgumentException("error_feed_no_data");
899 } 895 }
900 896
901 NodeList nodes = (NodeList) XMLUtils.xpath( 897 NodeList nodes = (NodeList) XMLUtils.xpath(
902 feed, 898 feed,
903 xpath, 899 XPATH_FEED_INPUT,
904 XPathConstants.NODESET, 900 XPathConstants.NODESET,
905 ArtifactNamespaceContext.INSTANCE); 901 ArtifactNamespaceContext.INSTANCE);
906 902
907 if (nodes == null || nodes.getLength() == 0) { 903 if (nodes == null || nodes.getLength() == 0) {
908 throw new IllegalArgumentException("error_feed_no_data"); 904 throw new IllegalArgumentException("error_feed_no_data");
983 * @param context The context object. 979 * @param context The context object.
984 */ 980 */
985 protected boolean isPreviousState(String stateId, Object context) { 981 protected boolean isPreviousState(String stateId, Object context) {
986 logger.debug("Determine if the state '" + stateId + "' is old."); 982 logger.debug("Determine if the state '" + stateId + "' is old.");
987 983
988 List<String> prevs = getPreviousStateIds(); 984 return getPreviousStateIds().contains(stateId);
989 if (prevs.contains(stateId)) {
990 return true;
991 }
992
993 return false;
994 } 985 }
995 986
996 987
997 /** 988 /**
998 * Computes the hash code of the entered values. 989 * Computes the hash code of the entered values.

http://dive4elements.wald.intevation.org