Search in sources :

Example 6 with DatabaseDesign

use of org.openntf.domino.design.DatabaseDesign in project org.openntf.domino by OpenNTF.

the class DesignClassTest method testDb.

protected void testDb(final Database db) {
    DatabaseDesign design = db.getDesign();
    System.out.println("Design: " + design.getClass().getName());
    DesignCollection<DesignBase> allDesign = design.getDesignElements("@ALL");
    Map<Class<?>, AtomicInteger> counter = new HashMap<Class<?>, AtomicInteger>();
    for (DesignBase des : allDesign) {
        if (!counter.containsKey(des.getClass())) {
            counter.put(des.getClass(), new AtomicInteger());
        }
        counter.get(des.getClass()).incrementAndGet();
    }
    int i = 0;
    int j = 0;
    for (ODPMapping mapping : ODPMapping.values()) {
        Class<? extends DesignBase> cls = mapping.getInstanceClass();
        if (cls == OtherDesignElement.class) {
        } else {
            DesignCollection<? extends DesignBase> ret = design.getDesignElements(cls);
            j = 0;
            for (@SuppressWarnings("unused") DesignBase b : ret) {
                i++;
                j++;
            }
            int cnt;
            if (!counter.containsKey(cls)) {
                cnt = 0;
            } else {
                cnt = counter.get(cls).get();
            }
            if (j == cnt) {
                System.out.println(j + "\t " + cnt + "\t" + cls.getName());
            } else {
                System.err.println(j + "\t " + cnt + "\t" + cls.getName());
            }
        // if (j == 0)
        // System.err.println("No design element of " + cls.getName() + " found");
        }
    }
    System.out.println("Total design elements " + i);
}
Also used : DatabaseDesign(org.openntf.domino.design.DatabaseDesign) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) DesignBase(org.openntf.domino.design.DesignBase) ODPMapping(org.openntf.domino.design.impl.ODPMapping)

Example 7 with DatabaseDesign

use of org.openntf.domino.design.DatabaseDesign in project org.openntf.domino by OpenNTF.

the class TestDatabasePropertyWrapper method testProperty.

public void testProperty(DbProperties prop) {
    HashMap<DbProperties, Boolean> props = new HashMap<DbProperties, Boolean>();
    props.put(prop, true);
    DatabaseDesign design = getNewSessionDesign();
    design.setDatabaseProperties(props);
    design.save();
    design = getNewSessionDesign();
    ArrayList<DbProperties> retProps = (ArrayList<DbProperties>) design.getDatabaseProperties();
    assertTrue(retProps.contains(prop));
    design = getNewSessionDesign();
    props.put(prop, false);
    design.setDatabaseProperties(props);
    design.save();
    design = getNewSessionDesign();
    retProps = (ArrayList<DbProperties>) design.getDatabaseProperties();
    assertFalse(retProps.contains(prop));
}
Also used : HashMap(java.util.HashMap) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) ArrayList(java.util.ArrayList) DbProperties(org.openntf.domino.design.DatabaseDesign.DbProperties)

Aggregations

DatabaseDesign (org.openntf.domino.design.DatabaseDesign)7 Database (org.openntf.domino.Database)5 Session (org.openntf.domino.Session)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DesignBase (org.openntf.domino.design.DesignBase)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 NotesException (lotus.domino.NotesException)1 Agent (org.openntf.domino.Agent)1 View (org.openntf.domino.View)1 DbProperties (org.openntf.domino.design.DatabaseDesign.DbProperties)1 DesignAgent (org.openntf.domino.design.DesignAgent)1 DesignColumn (org.openntf.domino.design.DesignColumn)1 DesignView (org.openntf.domino.design.DesignView)1 ODPMapping (org.openntf.domino.design.impl.ODPMapping)1 OnDiskProject (org.openntf.domino.design.impl.OnDiskProject)1 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)1