Search in sources :

Example 1 with DatabaseDesign

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

the class Subform method getExplicitSubformsRecursive.

/* (non-Javadoc)
	 * @see org.openntf.domino.design.AnyFormOrSubform#getExplicitSubformsRecursive(java.util.List)
	 */
@Override
public List<String> getExplicitSubformsRecursive(final List<String> existingList) {
    Database db = getAncestorDatabase();
    DatabaseDesign dbDesign = db.getDesign();
    XMLNodeList nodes = getSubformNodes();
    ArrayList<String> subforms = new ArrayList<String>();
    for (XMLNode node : nodes) {
        // $NON-NLS-1$
        String name = node.getAttribute("name");
        if (!Strings.isBlankString(name)) {
            if (!existingList.contains(name)) {
                // $NON-NLS-1$
                existingList.add(node.getAttribute("name"));
                org.openntf.domino.design.Subform sf = dbDesign.getSubform(name);
                existingList.addAll(sf.getExplicitSubformsRecursive(subforms));
            }
        }
    }
    return existingList;
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) Database(org.openntf.domino.Database) ArrayList(java.util.ArrayList) XMLNodeList(org.openntf.domino.utils.xml.XMLNodeList)

Example 2 with DatabaseDesign

use of org.openntf.domino.design.DatabaseDesign 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 3 with DatabaseDesign

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

the class Engage17DesignView method run.

@Override
public void run() {
    Session sess = Factory.getSession(SessionType.NATIVE);
    Database extLib = sess.getDatabase("oda_1.nsf");
    View contacts = extLib.getView("AllContactsProgrammatic");
    if (null != contacts) {
        contacts.remove();
    }
    DatabaseDesign dbDesign = extLib.getDesign();
    DesignView newView = dbDesign.createView();
    newView.setSelectionFormula("SELECT Form=\"Contact\"");
    newView.setName("AllContactsProgrammatic");
    DesignColumn col = newView.addColumn();
    col.setItemName("State");
    col.setSortOrder(SortOrder.ASCENDING);
    col.setTitle("STATE");
    col.setCategorized(true);
    DesignColumn name = newView.addColumn();
    name.setFormula("FirstName+\" \"+LastName");
    name.setSortOrder(SortOrder.ASCENDING);
    name.setTitle("NAME");
    DesignColumn name2 = newView.addColumn();
    name2.setFormula("LastName");
    name2.setSortOrder(SortOrder.ASCENDING);
    name2.setTitle("NAME");
    DesignColumn city = newView.addColumn();
    city.setItemName("City");
    city.setTitle("CITY");
    city.setResortOrder(ResortOrder.ASCENDING);
    city.setSecondarySortColumn(2);
    newView.save();
}
Also used : DesignColumn(org.openntf.domino.design.DesignColumn) DesignView(org.openntf.domino.design.DesignView) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) Database(org.openntf.domino.Database) View(org.openntf.domino.View) DesignView(org.openntf.domino.design.DesignView) Session(org.openntf.domino.Session)

Example 4 with DatabaseDesign

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

the class XotsNsfScanner method scanDatabase.

/**
 * @param session
 * @param db
 * @return true, if the database has XOTS-Classes
 * @throws @throws
 *             ServletException
 */
protected Future<List<ScheduleData>> scanDatabase(final Database db) {
    // NTF Keeping JG's implementation since he made an enhancement to the IconNote class for it! :)
    log_.finest("Scanning database " + db.getApiPath() + " for Xots Tasklets");
    try {
        Database template = db.getXPageSharedDesignTemplate();
        DatabaseDesign design = template == null ? db.getDesign() : template.getDesign();
        if (design.isAPIEnabled()) {
            log_.info("ODA enabled database: " + db.getApiPath());
            return Xots.submit(new XotsClassScanner(db.getApiPath()));
        }
    // 
    // 
    // 
    // 
    // 
    // IconNote icon = design.getIconNote();
    // 
    // if (icon != null) {
    // String[] xotsClassNames = icon.getXotsClassNames();
    // if (xotsClassNames != null && xotsClassNames.length > 0) {
    // if (log_.isLoggable(Level.FINE)) {
    // log_.fine("Adding Xots Tasklets for database " + db.getApiPath());
    // }
    // 
    // //					String dbPath = db.getFilePath().replace('\\', '/');
    // //					dbPath = NSFService.FILE_CASE_INSENSITIVE ? dbPath.toLowerCase() : dbPath;
    // //					if (!StringUtil.isEmpty(db.getServer())) {
    // //						dbPath = db.getServer() + "!!" + dbPath;
    // //					}
    // //
    // //					NSFComponentModule module = OpenntfHttpService.sGetNsfService().loadModule(dbPath);
    // //
    // //					Runnable loader = new LoaderRunnable(db.getApiPath(), xotsClassNames, module);
    // //					XotsDaemon.addToQueue(loader);
    // return true;
    // }
    // }
    } catch (UserAccessException uae) {
        Factory.println(this, "WARNING: " + uae.getMessage());
        // we don't log the warning in the log, as this may confuse admins.
        log_.log(Level.INFO, uae.getMessage(), uae);
    } catch (FileNotFoundException e) {
        Factory.println(this, "WARNING: " + e.getMessage());
        log_.log(Level.INFO, e.getMessage(), e);
    }
    return null;
}
Also used : DatabaseDesign(org.openntf.domino.design.DatabaseDesign) Database(org.openntf.domino.Database) FileNotFoundException(java.io.FileNotFoundException) UserAccessException(org.openntf.domino.exceptions.UserAccessException)

Example 5 with DatabaseDesign

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

the class AgentLog method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    try {
        Session sess = Factory.getSession(SessionType.NATIVE);
        Database db = sess.getDatabase("PrivateTest.nsf");
        DatabaseDesign dbDesign = db.getDesign();
        StringBuilder sb = new StringBuilder();
        for (Agent agent : db.getAgents()) {
            if (null != agent.getLastRunDate()) {
                DesignAgent agentDesign = dbDesign.getAgent(agent.getActualName());
                sb.append(agentDesign.getRunLog());
                addNewLine(sb);
                List<String> strings = agentDesign.getRunLogAsList();
                sb.append("Lines = " + strings.size());
                addNewLine(sb);
                sb.append("Duration = " + agentDesign.getLastRunDuration() + " seconds");
                addNewLine(sb);
                sb.append("Exceeded timeout? " + agentDesign.isLastRunExceededTimeLimit());
                addNewLine(sb);
            }
        }
        System.out.println(sb.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DesignAgent(org.openntf.domino.design.DesignAgent) Agent(org.openntf.domino.Agent) DatabaseDesign(org.openntf.domino.design.DatabaseDesign) Database(org.openntf.domino.Database) DesignAgent(org.openntf.domino.design.DesignAgent) Session(org.openntf.domino.Session)

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