Package de.netsysit.model

Examples of de.netsysit.model.PolicyModel


     * @param policies A List which includes all the policies
     * @return A PolicyModel which is the parent-policy or null
     */
    public static PolicyModel getParentPolicy(PolicyModel policy, List<PolicyModel> policies) {
        for(int i=0; i<policies.size(); i++) {
            PolicyModel parent = policies.get(i);
            PolicyModel fb = parent.getFallback();
            if((fb != null) && (fb.equals(policy)))
                return parent;
        }      
        return null;
    }
View Full Code Here


     */
    public static void setPolicyRanks(List<PolicyModel> list, boolean refresh) {
        int size = list.size();
        int current = size;
        for (int i = 0; i < size; i++) {
            PolicyModel p = list.get(i);

            if(getParentPolicy(p, list) == null) {             
                for(; p != null; p = p.getFallback()) {
                    p.setRank(current);
                    current--;   
                }
            }
        }

View Full Code Here

     * This method returns a PolicyModel which only is used to display that
     * no policy has been selected. It will not be saved in the database.
     * @return A PolicyModel
     */
    public static PolicyModel getDummyPolicy() {
        PolicyModel dummy = new PolicyModel();
        dummy.setName(rb.getString("nopolicy"));
        dummy.setId(13377331);
       
        return dummy;
    }
View Full Code Here

                            currentPolicies = dbModel.getCPolicies();
                        } else if (activeLevel == PolicyLevel.I) {
                            currentPolicy.addPropertyChangeListener((ChangeListModel) policyIPoliciesLst.getModel());
                            currentPolicies = dbModel.getIPolicies();
                        }
                        PolicyModel prevPolicy = (PolicyModel) evt.getOldValue();
                        if (prevPolicy != null) {
                            prevPolicy.removePropertyChangeListener(policyPcl);
                        }
                        fillPolicyGUI();
                    } else {
                        ActionFactory.get(ActionKey.POLICY_CHOOSEFB).setEnabled(false);
                    }
View Full Code Here

    }

    private void fillTree() {
        PersonalTreeNode root = new PersonalTreeNode("root", true);
        DefaultTreeModel tm = new DefaultTreeModel(root);
        PolicyModel p1 = currentPolicy;

        boolean parentexists = true;
        while (parentexists) {
            parentexists = false;
            for (PolicyModel p2 : currentPolicies) {
                if (p2.getFallback() == p1) {
                    p1 = p2;
                    parentexists = true;
                }
            }
        }

        PersonalTreeNode tn1 = null;
        if (p1 == currentPolicy) {
            tn1 = addNode(root, p1, true, tm);
        } else {
            tn1 = addNode(root, p1, false, tm);
        }

        PersonalTreeNode parent = tn1;
        PolicyModel p2 = null;
        PolicyModel fb = p1.getFallback();
        if (fb != null) {
            while (fb != null) {
                for (PolicyModel temp : currentPolicies) {
                    if (temp == fb) {
                        p2 = temp;
View Full Code Here

        return label;
    }
   
    private void setFallBack() {
        PolicyModel fallBack = currentPolicy.getFallback();
        if (fallBack != null) {
            policyFallBackLbl2.setText("<html><u>" + currentPolicy.getFallback().getName() + "</u></html>");
            policyFallBackLbl2.setEnabled(true);
        } else {
            policyFallBackLbl2.setText(rb.getString("notchosen"));
View Full Code Here

    }
   
    public void createPolicy() {
        //policyTree.setModel(new DefaultTreeModel(new PersonalTreeNode("root", true)));
        Map<ActionTupel, String> actions = null;  
        PolicyModel policy = new PolicyModel();
        policy.setId(PolicyUtilities.getNewPolicyId());
        policy.setName(rb.getString("newpolicy") + "_" + new Integer(policy.getId()).toString());
        policy.setLevel(activeLevel);
        switch(activeLevel) {
            case A:
                 actions = dbModel.getAActions();
                 policy.setAction(new ActionModel(actions, "-1"));
                if(dbModel.addAPolicy(policy)) {
                    PolicyUtilities.setPolicyRanks(dbModel.getAPolicies(), true);
                    dbModel.setCurrentPolicy(policy);
                    policyAPoliciesLst.setModel(dbModel.getAPoliciesAsListModel());
                    currentPolicy.addPropertyChangeListener((ChangeListModel) policyAPoliciesLst.getModel());
                }               
                break;
            case C:
                actions = dbModel.getCActions();
                policy.setAction(new ActionModel(actions, "-1"));
                if(dbModel.addCPolicy(policy)) {
                    PolicyUtilities.setPolicyRanks(dbModel.getCPolicies(), true);
                    dbModel.setCurrentPolicy(policy);
                    policyCPoliciesLst.setModel(dbModel.getCPoliciesAsListModel());
                    currentPolicy.addPropertyChangeListener((ChangeListModel) policyCPoliciesLst.getModel());
                }   
                break;
            case I:
                policy.setRank(policyIPoliciesLst.getModel().getSize()+1);
                actions = dbModel.getIActions();
                policy.setAction(new ActionModel(actions, "-1"));
                if(dbModel.addIPolicy(policy)) {
                    PolicyUtilities.setPolicyRanks(dbModel.getIPolicies(), true);
                    dbModel.setCurrentPolicy(policy);
                    policyIPoliciesLst.setModel(dbModel.getIPoliciesAsListModel());
                    currentPolicy.addPropertyChangeListener((ChangeListModel) policyIPoliciesLst.getModel());
View Full Code Here

            for (PolicyModel policy = currentPolicy.getFallback(); policy != null; policy = policy.getFallback()) {
                references.add(policy);
            }
           
                // alle Elternpolicies zur Fallback ermitteln
            PolicyModel parent = PolicyUtilities.getParentPolicy(currentPolicy, currentPolicies);
            if(parent != null)  {
                while(parent != null) {
                    references.add(0, parent);
                    parent = PolicyUtilities.getParentPolicy(parent, currentPolicies);
                }
            }
           
                // Messagestring aufbauen
            String temp = "";
            String message = "";
            for(int x=0; x<references.size(); x++) {
                PolicyModel p = references.get(x);
                if(!p.equals(currentPolicy))
                    temp += "<b>" + references.get(x) + "</b></center><br>";
                else
                    temp += references.get(x) + "</center><br>";
            }
           
View Full Code Here

            policies.get(i).setFallback(null);
        }
    }
   
    private boolean checkPolicyReferences(PolicyModel policy, List<PolicyModel> policies) {
        PolicyModel fb = policy.getFallback();
        boolean isChild = false;
       
        for(int i=0; i<policies.size(); i++) {
            if(policies.get(i).getFallback() == policy) {
                isChild = true;
View Full Code Here

       
        map.put(ActionKey.POLICY_CHOOSEFB, new PolicyAction(ActionKey.POLICY_CHOOSEFB, rb.getString("choosefallback")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                PolicyModel policy = dbModel.getCurrentPolicy();
                List<PolicyModel> currentPolicies = null;
                PolicyLevel level = dbModel.getActiveLevel();

                if (level == PolicyLevel.A) {
                    currentPolicies = dbModel.getAPolicies();
                } else if (level == PolicyLevel.C) {
                    currentPolicies = dbModel.getCPolicies();
                } else if (level == PolicyLevel.I) {
                    currentPolicies = dbModel.getIPolicies();
                }

                List<PolicyModel> list = new ArrayList<PolicyModel>(currentPolicies);
                list.remove(policy); // die darf sowieso nicht drin sein
                for (Iterator<PolicyModel> it = list.iterator(); it.hasNext();) {
                    PolicyModel next = it.next();
                    if (!PolicyUtilities.isValidPolicyFallback(policy, next)) {
                        it.remove(); // entferne alle invaliden
                    } else {
                            // prüfen, ob Policy schon Elternteil einer anderen Policy ist
                        for (int i=0; i<currentPolicies.size(); i++) {
                            PolicyModel ref = currentPolicies.get(i);
                            if(!ref.equals(next))
                                if(PolicyUtilities.isParentPolicy(ref, next))
                                    it.remove();
                        }
                    }
                }
               
                PolicyModel p = PolicyUtilities.getDummyPolicy();

                if ((list.isEmpty()) && (policy.getFallback() == null)) {
                    if(PolicyUtilities.isShowWarnings()) {
                        mb = PolicyUtilities.getMessageBundle();
                        PolicyUtilities.showMessageDialog(mb.getString("nofbavailable"), JOptionPane.INFORMATION_MESSAGE);
                   
                } else {
                    list.add(p);
                    Object[] policies = list.toArray();

                    FallBackChooserDialog dlg = new FallBackChooserDialog();
                    dlg.showDialog(policies);
                    Object result = dlg.getResult();
                    if (result != null) {
                        PolicyModel fb = (PolicyModel) result;
                        if(fb.equals(p))
                            dbModel.getCurrentPolicy().setFallback(null);
                        else
                            dbModel.getCurrentPolicy().setFallback((PolicyModel) dlg.getResult());

                        PolicyUtilities.setPolicyRanks(currentPolicies, true);
View Full Code Here

TOP

Related Classes of de.netsysit.model.PolicyModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.