Giter VIP home page Giter VIP logo

Comments (16)

marat-gainullin avatar marat-gainullin commented on August 17, 2024

No. It is not possible.
You can allways inspect entity property of changelog item and select a specific module and call its methods.

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Understood. I also wanna say that we tried to implement validator last week but it throws an error. I will post stack trace at monday, when will be in office.

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

This is what happens after trying to save any change log in application which contains empty template validator (validate() function just make a log entry, @validator annotation without specified data source name). Tested with making some data changes and sending it back to the server. After that changes are not saved.

12-Sep-2016 09:27:57.068 SEVERE [platypus-worker-pool-1-thread-25] com.eas.client.DatabasesClient.lambda$commit$26 null
 com.eas.script.NoPublisherException: JavaScript API integrity check failed. No publisher function.
    at com.eas.client.changes.Update.getPublished(Update.java:53)
    at com.eas.script.Scripts$Space.toJs(Scripts.java:493)
    at com.eas.script.Scripts$Space.toJs(Scripts.java:502)
    at com.eas.client.ScriptedDatabasesClient.lambda$validate$2(ScriptedDatabasesClient.java:179)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at com.eas.client.ScriptedDatabasesClient.validate(ScriptedDatabasesClient.java:177)
    at com.eas.client.ScriptedDatabasesClient.apply(ScriptedDatabasesClient.java:83)
    at com.eas.client.DatabasesClient.lambda$commit$26(DatabasesClient.java:500)
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1691)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at com.eas.client.DatabasesClient.commit(DatabasesClient.java:498)
    at com.eas.server.handlers.CommitRequestHandler.lambda$handle$1(CommitRequestHandler.java:139)
    at com.eas.server.handlers.CommitRequestHandler$ChangesSortProcess.complete(CommitRequestHandler.java:117)
    at com.eas.server.handlers.CommitRequestHandler.lambda$null$2(CommitRequestHandler.java:161)
    at com.eas.client.queries.LocalQueriesProxy.lambda$getQuery$1(LocalQueriesProxy.java:90)
    at com.eas.script.Scripts$Space.lambda$process$3(Scripts.java:667)
    at com.eas.script.Scripts$Space.lambda$process$4(Scripts.java:703)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

from platypus-js.

marat-gainullin avatar marat-gainullin commented on August 17, 2024

Ensure please, that you have dependencies from update.js, insert.js, delete.js, command.js modules in your validator. May be we should fix validator module template.

Also, can you clarify if global API is used by your application?

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Nope, AMD is used right now

from platypus-js.

marat-gainullin avatar marat-gainullin commented on August 17, 2024

And how about dependencies, mentioned earlier?

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Dependecies have written down just about 1 minute ago. There was also added @stateless annotation. And it works fine right now.
Looks like fixing validator template is the fastest way. Thanks.

from platypus-js.

marat-gainullin avatar marat-gainullin commented on August 17, 2024

How do you think, should we add auto dependencies injection in Platypus.js code to avoid "unused" dependencies?

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

@marat-gainullin it better to be.
But may be there is another way like checking with annotations in specific types of modules like validator.
E.g. we have core/update, core/insert etc. dependencies. Is it possible to force platypus inject they stealthy like user never know it's used. Like it happens with global API P.*. Is it possible?

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Okay, there is another validator issue.
Here is stacktrace

15-Sep-2016 10:38:31.017 SEVERE [platypus-worker-pool-1-thread-15] com.eas.client.DatabasesClient.lambda$commit$26 null
 com.eas.script.NoPublisherException: JavaScript API integrity check failed. No publisher function.
    at com.eas.client.changes.ChangeValue.getPublished(ChangeValue.java:52)
    at jdk.nashorn.internal.scripts.Script$Recompilation$78$1685A$boxing.L:3$boxAsJs(boxing:56)
    at jdk.nashorn.internal.scripts.Script$Recompilation$78$1685A$boxing.L:3$boxAsJs(boxing:70)
    at jdk.nashorn.internal.scripts.Script$Recompilation$77$888$update.L:3$Update$get(core/update:32)
    at jdk.nashorn.internal.runtime.UserAccessorProperty.invokeObjectGetter(UserAccessorProperty.java:290)
    at jdk.nashorn.internal.runtime.UserAccessorProperty.getObjectValue(UserAccessorProperty.java:196)
    at jdk.nashorn.internal.runtime.FindProperty.getObjectValue(FindProperty.java:229)
    at jdk.nashorn.internal.runtime.ScriptObject.get(ScriptObject.java:2860)
    at jdk.nashorn.internal.runtime.ScriptObject.get(ScriptObject.java:2877)
    at jdk.nashorn.internal.objects.NativeJSON.str(NativeJSON.java:214)
    at jdk.nashorn.internal.objects.NativeJSON.JO(NativeJSON.java:290)
    at jdk.nashorn.internal.objects.NativeJSON.str(NativeJSON.java:268)
    at jdk.nashorn.internal.objects.NativeJSON.stringify(NativeJSON.java:196)
    at jdk.nashorn.internal.scripts.Script$Recompilation$75$1237AAAA$GlobalServerValidator.L:8$module_constructor$validate(Сервер/Валидаторы/GlobalServerValidator:22)
    at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:645)
    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
    at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
    at com.eas.client.ScriptedDatabasesClient.lambda$validate$2(ScriptedDatabasesClient.java:179)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at com.eas.client.ScriptedDatabasesClient.validate(ScriptedDatabasesClient.java:177)
    at com.eas.client.ScriptedDatabasesClient.apply(ScriptedDatabasesClient.java:83)
    at com.eas.client.DatabasesClient.lambda$commit$26(DatabasesClient.java:500)
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1691)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
    at com.eas.client.DatabasesClient.commit(DatabasesClient.java:498)
    at com.eas.server.handlers.CommitRequestHandler.lambda$handle$1(CommitRequestHandler.java:139)
    at com.eas.server.handlers.CommitRequestHandler$ChangesSortProcess.complete(CommitRequestHandler.java:117)
    at com.eas.server.handlers.CommitRequestHandler.lambda$null$2(CommitRequestHandler.java:161)
    at com.eas.client.queries.LocalQueriesProxy.lambda$getQuery$1(LocalQueriesProxy.java:90)
    at com.eas.script.Scripts$Space.lambda$process$3(Scripts.java:667)
    at com.eas.script.Scripts$Space.lambda$process$4(Scripts.java:703)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

This happens when I try to access change log inside validator. The funny thing about that is this template code works fine:

this.validate = function (aLog, aDatasource, aOnSuccess, aOnFailure) {
            Logger.info("GlobalServerValidator. aLog.length: " + aLog.length + "; aDatasource: " + aDatasource + ";");
            if (aOnSuccess) {
                // TODO: place your asynchronous validation code here
            } else {
                // TODO: place your synchronous validation code here
            }
        };

This works fine and prints out this:

15-Sep-2016 10:38:30.975 INFO [platypus-worker-pool-1-thread-15] jdk.nashorn.internal.scripts.Script$Recompilation$76$2129A$logger.L:3$value-3 GlobalServerValidator. aLog.length: 1; aDatasource: tk;

But if I try to access aLog, it fails with stacktrace posted at the begining.
E.g. eve this simple code fails:

Logger.info(JSON.stringify(aLog[0]));

from platypus-js.

marat-gainullin avatar marat-gainullin commented on August 17, 2024

It is because aLog is native Java array, not js array. And so it can't be JSONed. Try Java.from(aLog) before JSON.stringify(...).
Also, try to add dependency change-value.js to the validator module.

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Works fine now with core/change-value.

from platypus-js.

marat-gainullin avatar marat-gainullin commented on August 17, 2024

JSON.stringify doesn't work with non enumerable properties (e.g. Update.keys). It skips such properties and generates '{}' text for objects with none of enumerable properties. The changeling entries have non enumerable properties. So, you should develop your own JSON-er or take one already implemented in Platypus.js low level code.

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Validator still laughing at me :(
This code runs exactly as it is written here.

var log = Java.from(aLog); //Cause aLog is native
var action = log[0]; //First element
Logger.info(JSON.stringify(action)); //This prints 'undefined'
Logger.info(JSON.stringify(action.entity)); //And this prints correct name of entity

How can it be possible?

from platypus-js.

marat-gainullin avatar marat-gainullin commented on August 17, 2024

It is because JSON.stringify() works only with native JS objects. Anyway this situation is to be investigated.

from platypus-js.

valeriy-maslov avatar valeriy-maslov commented on August 17, 2024

Another funny thing

var log = Java.from(aLog); //Cause aLog is native
Logger.info(JSON.stringify(log)); //Prints correct JSON object structure

from platypus-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.