public <V extends EvolutionNode> EvolutionPolicy<V> get(EventType eventType /*, V eventNode*/) { for (EvolutionPolicy<V> u : this) { if (u.getSourceEvent().getEventType() == eventType /* && u.getSourceEvent().getEventNode().equals(eventNode )*/) { return u; } } return null; }
public void exportPoliciesToFile(File file) { try { BufferedWriter out = new BufferedWriter(new FileWriter(file)); for (V v : this.getVertices()) { for (EvolutionPolicy<V> p : v.getPolicies()) { out.write(v + ": " + p.toString() + ";"); out.newLine(); } } out.close(); } catch (IOException e) { e.printStackTrace(); } }
/* * gets the prevailing policy in a module (e.g. a query, relation, view) */ private PolicyType getPrevailingPolicy( EvolutionEvent<V> event, V nr, PolicyType previousPolicyType) { EvolutionPolicies policies = nr.getPolicies(); // if policy for this event exist override previousPolicy coming from provider node for (EvolutionPolicy<V> nrPolicy : policies) { if ((nrPolicy.getSourceEvent().getEventNode().equals(event.getEventNode())) && (nrPolicy.getSourceEvent().getEventType() == event.getEventType())) { return nrPolicy.getPolicyType(); } } // If no policy is returned check parents' policy for this event to override provider's policy if (this.getParentNode(nr) != null) { EvolutionEvent<V> newEvent = new EvolutionEvent<V>(/*nr,*/ event.getEventType()); return getPrevailingPolicy(newEvent, this.getParentNode(nr), previousPolicyType); } // if no self or parents policy exists then return provider's policy return previousPolicyType; }