Search in sources :

Example 26 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class FormulaTester method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.CURRENT);
    Formula formula = new Formula();
    String source = "REM {Begin_Do_Not_Tag};\r\n" + "\r\n" + "SenderName := @If(SendTo = \"\";EnterSendTo;SendTo);\r\n" + "Send := @Subset(SenderName; 1);\r\n" + "CN1 := @Trim(@Name([CN]; Send));\r\n" + "CN := @If(@Contains(@Right(Send;\"@\");\">\") & CN1 = \"\";@Trim(Send); CN1);\r\n" + "G := @If(CN = \"\"; @Name([G]; @Subset(SenderName; 1)); \"\");\r\n" + "S := @If(CN = \"\"; @Name([S]; @Subset(SenderName; 1)); \"\");\r\n" + "Person := @If(CN != \"\"; CN; G + \" \" + S);\r\n" + "@If(@Left(Person;1)=\"\\\"\" & @Right(Person;1)=\"\\\"\"; @LeftBack(@RightBack(Person;1);1); Person);\r\n" + "REM {End_Do_Not_Tag};";
    formula.setExpression(source);
    org.openntf.domino.helpers.Formula.Parser parser = formula.getParser();
    if (parser != null) {
        parser.parse();
        Set<String> literals = parser.getLiterals();
        System.out.println("BEGIN LITERALS");
        for (String literal : literals) {
            System.out.print(literal + ", ");
        }
        System.out.println("END LITERALS");
        Set<String> functions = parser.getFunctions();
        System.out.println("BEGIN FUNCTIONS");
        for (String function : functions) {
            System.out.print(function + ", ");
        }
        System.out.println("END FUNCTIONS");
        Set<String> localVars = parser.getLocalVars();
        System.out.println("BEGIN LOCAL VARIABLES");
        for (String var : localVars) {
            System.out.print(var + ", ");
        }
        System.out.println("END LOCAL VARIABLES");
        Set<String> fieldVars = parser.getFieldVars();
        System.out.println("BEGIN FIELDS");
        for (String var : fieldVars) {
            System.out.print(var + ", ");
        }
        System.out.println("END FIELDS");
        Set<String> envVars = parser.getEnvVars();
        System.out.println("BEGIN ENVIRONMENTS");
        for (String var : envVars) {
            System.out.print(var + ", ");
        }
        System.out.println("END ENVIRONMENTS");
        Set<String> keywords = parser.getKeywords();
        System.out.println("BEGIN KEYWORDS");
        for (String var : keywords) {
            System.out.print(var + ", ");
        }
        System.out.println("END KEYWORDS");
        Set<String> numbers = parser.getNumberLiterals();
        System.out.println("BEGIN NUMBERS");
        for (String var : numbers) {
            System.out.print(var + ", ");
        }
        System.out.println("END NUMBERS");
    } else {
        System.out.println("Parser was null?");
    }
}
Also used : Formula(org.openntf.domino.helpers.Formula) Session(org.openntf.domino.Session)

Example 27 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class FormulaTester2 method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.NATIVE);
    String source = "@TextToTime(\"01/01/2014-02/15/2014\")";
    Object raw = session.evaluate(source);
    if (raw instanceof Vector) {
        for (Object curraw : (Vector) raw) {
            System.out.println("Found a " + curraw.getClass());
        }
    }
}
Also used : Vector(java.util.Vector) Session(org.openntf.domino.Session)

Example 28 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class GraphExamples method getMe.

public Attendee getMe() {
    Session session = Factory.getSession(SessionType.CURRENT);
    String myName = session.getEffectiveUserName();
    return getConference().getAttendee(myName, true);
}
Also used : Session(org.openntf.domino.Session)

Example 29 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class SessionsByTimeslot method run.

@Override
public void run() {
    long testStartTime = System.nanoTime();
    marktime = System.nanoTime();
    try {
        timelog("Beginning Sessions By TimeSlot...");
        ConferenceGraph graph = new ConferenceGraph();
        Session session = Factory.getSession(SessionType.CURRENT);
        String myName = session.getEffectiveUserName();
        Attendee att = graph.getAttendee(myName, false);
        Ordering<TimeSlot> byStart = new Ordering<TimeSlot>() {

            @Override
            public int compare(final TimeSlot t1, final TimeSlot t2) {
                return t1.getStartTime().compareTo(t2.getStartTime());
            }
        };
        Iterable<TimeSlot> times = graph.getTimeSlots();
        List<TimeSlot> timesSorted = byStart.sortedCopy(times);
        for (TimeSlot ts : timesSorted) {
            System.out.println("Sessions running from " + DATE_FORMAT.format(ts.getStartTime().getTime()) + " to " + DATE_FORMAT.format(ts.getEndTime().getTime()));
            System.out.println(ts.getDuration());
            Iterable<Event> presentations = ts.getEvents();
            for (Event evt : presentations) {
                if (evt instanceof Presentation) {
                    Presentation pres = (Presentation) evt;
                    System.out.println(pres.getSessionId() + ": " + pres.getTitle());
                }
            }
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
    long testEndTime = System.nanoTime();
    System.out.println("Completed " + getClass().getSimpleName() + " run in " + ((testEndTime - testStartTime) / 1000000) + " ms");
}
Also used : TimeSlot(org.openntf.conference.graph.TimeSlot) Presentation(org.openntf.conference.graph.Presentation) ConferenceGraph(org.openntf.conference.graph.ConferenceGraph) Attendee(org.openntf.conference.graph.Attendee) Ordering(com.google.common.collect.Ordering) Event(org.openntf.conference.graph.Event) Session(org.openntf.domino.Session)

Example 30 with Session

use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.

the class Connect17Documents method run.

@Override
public void run() {
    Session sess = Factory.getSession(SessionType.NATIVE);
    Database extLib = sess.getDatabase("odademo/oda_1.nsf");
    View contacts = extLib.getView("AllContacts");
    View threads = extLib.getView("AllThreadsByAuthor");
    Document doc = contacts.getFirstDocument();
    // Clears changes this function already made
    resetDoc(doc);
    Document newDoc = extLib.createDocument();
    doc.copyAllItems(newDoc, true);
    String prevDocAsJson = doc.toJson(true);
    doc.appendItemValue("State", "AZ");
    doc.replaceItemValue("DateTimeField", new Date());
    doc.replaceItemValue("DateOnlyField", new java.sql.Date(System.currentTimeMillis()));
    System.out.println(doc.getFirstItem("DateOnlyField").getValues());
    doc.replaceItemValue("TimeOnlyField", new java.sql.Time(System.currentTimeMillis()));
    System.out.println(doc.getFirstItem("TimeOnlyField").getValues());
    doc.replaceItemValue("EmptyDate", "");
    Date blankDate = doc.getItemValue("EmptyDate", Date.class);
    System.out.println(blankDate);
    ArrayList<String> list = new ArrayList<String>();
    list.add("Value 1");
    list.add("Value 2");
    doc.replaceItemValue("MVField", list);
    doc.replaceItemValue("DocAsJson", prevDocAsJson);
    HashMap<String, String> mapField = new HashMap<String, String>();
    DocumentCollection dc = threads.getAllDocumentsByKey(doc.getItemValueString("FullName"));
    for (Document tmp : dc) {
        mapField.put(tmp.getUniversalID(), tmp.getItemValueString("Title"));
    }
    doc.put("MapField", mapField);
    BigDecimal decimal = new BigDecimal("2.5");
    doc.replaceItemValue("BigDecimalField", decimal);
    doc.replaceItemValue("EnumField", Fixes.FORCE_HEX_LOWER_CASE);
    doc.save();
    HashMap tmp = doc.getItemValue("MapField", HashMap.class);
    System.out.println(tmp.size());
    System.out.println(doc.getMetaversalID());
    System.out.println(doc.getItemValueString("EnumField"));
    java.sql.Date sqlDt = doc.getItemValue("DateTimeField", java.sql.Date.class);
    System.out.println(sqlDt);
    java.sql.Time sqlTime = doc.getItemValue("DateTimeField", java.sql.Time.class);
    System.out.println(sqlTime);
    System.out.println(doc.getItemValues("BigDecimalField", BigDecimal.class));
    System.out.println(doc.getFirstItem("MVField").getTypeEx());
    ArrayList<String> blank = new ArrayList<String>();
    doc.replaceItemValue("MVField", blank);
    System.out.println(doc.hasItem("MVField"));
    NamesList names = new NamesList();
    names.add("CN=Paul Withers/O=Intec");
    names.add("CN=Admin/O=Intec=PW");
    newDoc.replaceItemValue("Names", names);
    AuthorsList authors = new AuthorsList();
    authors.addAll(names);
    newDoc.replaceItemValue("Authors", authors);
    ReadersList readers = new ReadersList();
    readers.addAll(names);
    newDoc.replaceItemValue("Readers", readers);
    Item dt = newDoc.replaceItemValue("TestDate", "");
    Vector<DateTime> dates = new Vector();
    DateTime dt1 = sess.createDateTime("01/01/2017");
    DateTime dt2 = sess.createDateTime("02/01/2017");
    dates.add(dt1);
    dates.add(dt2);
    dt.setValues(dates);
    newDoc.save();
}
Also used : NamesList(org.openntf.domino.types.NamesList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Document(org.openntf.domino.Document) DocumentCollection(org.openntf.domino.DocumentCollection) View(org.openntf.domino.View) Date(java.util.Date) BigDecimal(java.math.BigDecimal) DateTime(org.openntf.domino.DateTime) Item(org.openntf.domino.Item) AuthorsList(org.openntf.domino.types.AuthorsList) Database(org.openntf.domino.Database) ReadersList(org.openntf.domino.types.ReadersList) Vector(java.util.Vector) Session(org.openntf.domino.Session)

Aggregations

Session (org.openntf.domino.Session)101 Database (org.openntf.domino.Database)73 Document (org.openntf.domino.Document)28 Test (org.junit.Test)25 View (org.openntf.domino.View)20 DbDirectory (org.openntf.domino.DbDirectory)11 ArrayList (java.util.ArrayList)10 DocumentCollection (org.openntf.domino.DocumentCollection)7 Vector (java.util.Vector)5 ViewEntry (org.openntf.domino.ViewEntry)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 NotesException (lotus.domino.NotesException)4 Item (org.openntf.domino.Item)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Agent (org.openntf.domino.Agent)3 NoteCollection (org.openntf.domino.NoteCollection)3