Search in sources :

Example 6 with Access

use of com.dexels.navajo.script.api.Access in project navajo by Dexels.

the class DomainObjectMapperTest method testSetInputProperties.

@Test
public void testSetInputProperties() throws Exception {
    TestPOJO tp = new TestPOJO();
    tp.setName("hallo");
    DomainObjectMapper dom = new DomainObjectMapper(tp);
    Access a = new Access();
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    a.setOutputDoc(doc);
    Message m = NavajoFactory.getInstance().createMessage(doc, "Test");
    doc.addMessage(m);
    a.setCurrentOutMessage(m);
    dom.load(a);
    dom.setInputProperties("name;birthdate");
    dom.store();
    assertNotNull(doc.getProperty("/Test/Name"));
    assertEquals("in", doc.getProperty("/Test/Name").getDirection());
    assertEquals("hallo", doc.getProperty("/Test/Name").getValue());
    assertNotNull(doc.getProperty("/Test/Something"));
    assertEquals("out", doc.getProperty("/Test/Something").getDirection());
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 7 with Access

use of com.dexels.navajo.script.api.Access in project navajo by Dexels.

the class DomainObjectMapperTest method testStoreWithSelectionProperty.

@Test
public void testStoreWithSelectionProperty() throws Exception {
    // The other way around, with an input Navajo with property that does
    // have an associated attribute.
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    Message m = NavajoFactory.getInstance().createMessage(doc, "MyMessage");
    doc.addMessage(m);
    Property p1 = NavajoFactory.getInstance().createProperty(doc, "Id", "string", "hello", 0, "", "in");
    Property p2 = NavajoFactory.getInstance().createProperty(doc, "Selection", "1", "", "in");
    m.addProperty(p1);
    m.addProperty(p2);
    // Add selections...
    Selection s1 = NavajoFactory.getInstance().createSelection(doc, "aap", "AAP", false);
    Selection s2 = NavajoFactory.getInstance().createSelection(doc, "noot", "NOOT", true);
    p2.addSelection(s1);
    p2.addSelection(s2);
    Access a = new Access();
    a.setInDoc(doc);
    DomainObjectMapper dom2 = new DomainObjectMapper();
    dom2.setCurrentMessageName("MyMessage");
    dom2.load(a);
    dom2.setObjectName("com.dexels.navajo.mapping.bean.Relation");
    dom2.store();
    Object o = dom2.getMyObject();
    assertNotNull(o);
    assertEquals(Relation.class, o.getClass());
    assertEquals("hello", ((Relation) o).getId());
    assertEquals("NOOT", ((Relation) o).getSelection());
}
Also used : Message(com.dexels.navajo.document.Message) Selection(com.dexels.navajo.document.Selection) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 8 with Access

use of com.dexels.navajo.script.api.Access in project navajo by Dexels.

the class DomainObjectMapperTest method testSetExcludedProperties.

@Test
public void testSetExcludedProperties() throws Exception {
    // TestPOJO tp = new TestPOJO();
    DomainObjectMapper dom = new DomainObjectMapper();
    dom.setObjectName("com.dexels.navajo.mapping.bean.TestPOJO");
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    Message m = NavajoFactory.getInstance().createMessage(doc, "Test");
    System.err.println("m = " + m);
    doc.addMessage(m);
    Property p1 = NavajoFactory.getInstance().createProperty(doc, "name", Property.STRING_PROPERTY, "nice", 0, "", "out");
    m.addProperty(p1);
    java.util.Date d = new java.util.Date();
    Property p2 = NavajoFactory.getInstance().createProperty(doc, "birthdate", Property.DATE_PROPERTY, null, 0, "", "out");
    p2.setAnyValue(d);
    m.addProperty(p2);
    Property p3 = NavajoFactory.getInstance().createProperty(doc, "something", Property.STRING_PROPERTY, "notnice", 0, "", "out");
    m.addProperty(p3);
    Access a = new Access();
    a.setInDoc(doc);
    a.setOutputDoc(NavajoFactory.getInstance().createNavajo());
    dom.load(a);
    dom.setExcludedProperties("something");
    dom.setCurrentMessageName("Test");
    dom.store();
    TestPOJO tp = (TestPOJO) dom.getMyObject();
    assertEquals("nice", tp.getName());
    assertEquals(d, tp.getBirthdate());
    assertNull(tp.getSomething());
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 9 with Access

use of com.dexels.navajo.script.api.Access in project navajo by Dexels.

the class AdminMap method getAsyncThreads.

@SuppressWarnings("rawtypes")
public AsyncProxy[] getAsyncThreads() {
    Map all = com.dexels.navajo.mapping.AsyncStore.getInstance().objectStore;
    Iterator iter = all.values().iterator();
    List<AsyncProxy> l = new ArrayList<>();
    while (iter.hasNext()) {
        AsyncMappable am = (AsyncMappable) iter.next();
        Access ac = com.dexels.navajo.mapping.AsyncStore.getInstance().accessStore.get(am.pointer);
        AsyncProxy o = new AsyncProxy();
        o.user = ac.rpcUser;
        o.rpcName = ac.rpcName;
        o.setPointer(am.getPointer());
        o.startDate = am.getStartDate();
        o.name = am.getName();
        o.startTime = am.getStartTime();
        o.running = am.getRunning();
        o.interrupt = am.getInterrupt();
        o.accessId = ac.accessID;
        o.totaltime = (int) (System.currentTimeMillis() - am.getStartDate().getTime());
        o.ipAddress = ac.ipAddress;
        o.host = ac.hostName;
        o.kill = am.kill;
        o.stackTrace = am.getStackTrace();
        o.lockClass = am.getLockClass();
        o.lockName = am.getLockName();
        o.lockOwner = am.getLockOwner();
        o.waiting = am.isWaiting();
        try {
            o.percReady = am.getPercReady();
        } catch (Exception e) {
            logger.error("Error: ", e);
        }
        l.add(o);
    }
    AsyncProxy[] objects = new AsyncProxy[l.size()];
    return l.toArray(objects);
}
Also used : AsyncMappable(com.dexels.navajo.mapping.AsyncMappable) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) Access(com.dexels.navajo.script.api.Access) Map(java.util.Map) UserException(com.dexels.navajo.script.api.UserException) MappableException(com.dexels.navajo.script.api.MappableException)

Example 10 with Access

use of com.dexels.navajo.script.api.Access in project navajo by Dexels.

the class AccessMap method setAccessId.

public void setAccessId(String id) throws UserException {
    this.accessId = id;
    if (accessId == null) {
        throw new UserException(-1, "Set accessId first");
    }
    Set<Access> all = com.dexels.navajo.server.DispatcherFactory.getInstance().getAccessSet();
    Iterator<Access> iter = all.iterator();
    while (iter.hasNext()) {
        Access a = iter.next();
        if (a.accessID.equals(accessId)) {
            this.myAccess = a;
            showDetails = true;
        }
    }
    if (!(showDetails)) {
        // Try async store
        myAccess = com.dexels.navajo.mapping.AsyncStore.getInstance().accessStore.get(id);
        if (myAccess != null) {
            showDetails = true;
        }
    }
}
Also used : Access(com.dexels.navajo.script.api.Access) UserException(com.dexels.navajo.script.api.UserException)

Aggregations

Access (com.dexels.navajo.script.api.Access)45 Navajo (com.dexels.navajo.document.Navajo)29 Message (com.dexels.navajo.document.Message)27 Test (org.junit.Test)18 Property (com.dexels.navajo.document.Property)15 Selection (com.dexels.navajo.document.Selection)14 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)12 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)12 TipiLink (com.dexels.navajo.expression.api.TipiLink)12 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)12 Optional (java.util.Optional)12 Operand (com.dexels.navajo.document.Operand)10 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)10 ArrayList (java.util.ArrayList)8 UserException (com.dexels.navajo.script.api.UserException)6 ResultMessage (com.dexels.navajo.adapter.messagemap.ResultMessage)5 Binary (com.dexels.navajo.document.types.Binary)4 HttpResource (com.dexels.navajo.resource.http.HttpResource)4 HttpResourceFactory (com.dexels.navajo.resource.http.HttpResourceFactory)4 Dispatcher (com.dexels.navajo.server.Dispatcher)4