Search in sources :

Example 1 with DesignBase

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

the class DesignClassTest method testDesignClass.

// @Test
public void testDesignClass() throws IOException {
    Session sess = Factory.getSession(SessionType.CURRENT);
    // Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/empty.ns9");
    // Database db = sess.getDatabase("D:/Daten/notesdaten_9/empty2.nsf");
    // Database db = sess.getDatabase("D:/Daten/notesdaten_9/localdb/proglib4work2.nsf");
    Database db = sess.getDatabase("srv-01-ndev2!!entwicklung/alex/proglib4work22.nsf");
    testDb(db);
    DatabaseDesign design = db.getDesign();
    // -X = no AgentData
    DesignCollection<DesignBase> elems = design.getDesignElements(// 
    "!@Contains($Flags;{X}) & !($TITLE={WEB-INF/classes/plugin/Activator.class}:{$BEProfileR7}) " + "");
    // + "& @IsAvailable($ACLDigest) ");
    // + "& @contains($TITLE;{gadproxy}) ");
    System.out.println("Count: " + elems.getCount());
    Path root = Paths.get("D:/daten/temp/ods3");
    OnDiskProject odp = new OnDiskProject(root);
    // PrintWriter pw = new PrintWriter(oFile);
    for (DesignBase elem : elems) {
        // + elem.getDocument().getItemValueString("$FLAGS"));
        try {
            odp.export(elem);
        // //elem.getDxlString(null)
        // String odp = elem.getOnDiskPath();
        // if (StringUtil.isEmpty(odp)) {
        // odp = elem.getNoteID() + ".note";
        // }
        // File odsFile = new File(root, odp);
        // System.out.println(elem.getClass().getName() + "\t\t\t" + odsFile);
        // odsFile.getParentFile().mkdirs(); // ensure the path exists
        // elem.writeOnDiskFile(odsFile);
        // if (elem instanceof HasMetadata) {
        // File meta = new File(odsFile.getAbsolutePath() + ".metadata");
        // ((HasMetadata) elem).writeOnDiskMeta(meta);
        // }
        } catch (Exception ne) {
            ne.printStackTrace();
        }
    // String path = "./" + elem.getOnDiskPath();
    // String ext = elem.getOnDiskExtension();
    // if (path != null && ext != null && !path.endsWith(ext))
    // path = path + ext;
    // pw.println(path + "\t'" + elem.getClass().getSimpleName() + "\t" + elem.getNoteID() + "\t" + elem.getName() + "\t"
    // + elem.getDocument().getItemValueString("$FLAGS"));
    // if (elem instanceof HasMetadata) {
    // pw.println(path + ".metadata");
    // }
    // if (elem instanceof CustomControl) {
    // pw.println(path + "-config");
    // }
    }
}
Also used : Path(java.nio.file.Path) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) DesignBase(org.openntf.domino.design.DesignBase) Database(org.openntf.domino.Database) OnDiskProject(org.openntf.domino.design.impl.OnDiskProject) IOException(java.io.IOException) OpenNTFNotesException(org.openntf.domino.exceptions.OpenNTFNotesException) NotesException(lotus.domino.NotesException) Session(org.openntf.domino.Session)

Example 2 with DesignBase

use of org.openntf.domino.design.DesignBase 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)

Aggregations

DatabaseDesign (org.openntf.domino.design.DatabaseDesign)2 DesignBase (org.openntf.domino.design.DesignBase)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 NotesException (lotus.domino.NotesException)1 Database (org.openntf.domino.Database)1 Session (org.openntf.domino.Session)1 ODPMapping (org.openntf.domino.design.impl.ODPMapping)1 OnDiskProject (org.openntf.domino.design.impl.OnDiskProject)1 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)1