Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java @ 6868:08e3c22500f3
Fix Analysis: Code simplification in facets.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 19 Aug 2013 16:29:28 +0200 |
parents | af13ceeba52a |
children | 6848c5c8fc23 |
comparison
equal
deleted
inserted
replaced
6867:0f3dad5d74a2 | 6868:08e3c22500f3 |
---|---|
59 */ | 59 */ |
60 @Override | 60 @Override |
61 public Object getData(Artifact artifact, CallContext context) { | 61 public Object getData(Artifact artifact, CallContext context) { |
62 logger.debug("FixReferenceEventsFacet.getData"); | 62 logger.debug("FixReferenceEventsFacet.getData"); |
63 | 63 |
64 if (artifact instanceof D4EArtifact) { | 64 if (!(artifact instanceof D4EArtifact)) { |
65 D4EArtifact flys = (D4EArtifact)artifact; | |
66 | |
67 CalculationResult res = | |
68 (CalculationResult) flys.compute(context, | |
69 ComputeType.ADVANCE, | |
70 false); | |
71 | |
72 FixResult result = (FixResult) res.getData(); | |
73 double currentKm = getCurrentKm(context); | |
74 | |
75 logger.debug("current km in FRE: " + currentKm); | |
76 | |
77 KMIndex<QWD []> kmQWs = result.getReferenced(); | |
78 KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); | |
79 QWD[] qwds = null; | |
80 if (kmQWsEntry != null) { | |
81 int ndx = index & 255; | |
82 qwds = kmQWsEntry.getValue(); | |
83 for (int i = 0; i < qwds.length; i++) { | |
84 if (qwds[i].getIndex() == ndx) { | |
85 return qwds[i]; | |
86 } | |
87 } | |
88 return null; | |
89 } | |
90 return null; | |
91 } | |
92 else { | |
93 logger.debug("Not an instance of FixationArtifact."); | 65 logger.debug("Not an instance of FixationArtifact."); |
94 return null; | 66 return null; |
95 } | 67 } |
68 | |
69 D4EArtifact flys = (D4EArtifact)artifact; | |
70 | |
71 CalculationResult res = | |
72 (CalculationResult) flys.compute(context, | |
73 ComputeType.ADVANCE, | |
74 false); | |
75 | |
76 FixResult result = (FixResult) res.getData(); | |
77 double currentKm = getCurrentKm(context); | |
78 | |
79 logger.debug("current km in FRE: " + currentKm); | |
80 | |
81 KMIndex<QWD []> kmQWs = result.getReferenced(); | |
82 KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); | |
83 if (kmQWsEntry != null) { | |
84 int ndx = index & 255; | |
85 for (QWD qwd: kmQWsEntry.getValue()) { | |
86 if (qwd.getIndex() == ndx) { | |
87 return qwd; | |
88 } | |
89 } | |
90 } | |
91 return null; | |
96 } | 92 } |
97 | 93 |
98 | 94 |
99 /** | 95 /** |
100 * Create a deep copy of this Facet. | 96 * Create a deep copy of this Facet. |