Author: svkrish
Date: Wed Mar 12 06:59:08 2008
New Revision: 636329
URL: http://svn.apache.org/viewvc?rev=636329&view=rev
Log:
adding this class that contains some utility methods used in computation of
policy intents and policysets
Added:
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
(with props)
Added:
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java?rev=636329&view=auto
==============================================================================
---
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
(added)
+++
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
Wed Mar 12 06:59:08 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Utility methods used during computation of PolicyIntents and PolicySets sets
+ */
+public class PolicyComputationUtils {
+ public static void addInheritedIntents(List<Intent> sourceList,
List<Intent> targetList) {
+ if (sourceList != null) {
+ targetList.addAll(sourceList);
+ }
+ }
+
+ public static void addInheritedPolicySets(List<PolicySet> sourceList,
List<PolicySet> targetList, boolean checkOverrides) {
+ //check overrides is true when policysets are to be copied from
componentType to component level
+ if ( checkOverrides ) {
+ //aggregate all the provided intents present in the target
+ List<Intent> targetProvidedIntents = new ArrayList<Intent>();
+ for ( PolicySet policySet : targetList ) {
+ targetProvidedIntents.addAll(policySet.getProvidedIntents());
+ }
+
+ //for every policy set in the source check if it provides one of
the intents that is
+ //already provided by the policysets in the destination and do not
copy them.
+ for ( PolicySet policySet : sourceList ) {
+ for ( Intent sourceProvidedIntent :
policySet.getProvidedIntents() ) {
+ if ( !targetProvidedIntents.contains(sourceProvidedIntent)
) {
+ targetList.add(policySet);
+ }
+ }
+ }
+ } else {
+ targetList.addAll(sourceList);
+ }
+ }
+
+}
Propchange:
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]