Page 1 of 2

rest service and compare value to db value

Posted: Mon Jan 12, 2015 3:04 pm
by karavidas jakolokoulos

i m building an app for the elections..in this app i ve build a rest service that takes data(votes,etc) from a .js file of another website,and presents them to some fields.the problem is that.on that js file,the creators provide only "party_id" and not "party_name" which is contained in another .js file.i copied the id's and the names to my database.and now i want that:when the first js file gives the "Party_id",to search the database and provide me the "party_name"..what i want to do is to compare the values given from the rest service and the database collection and to return the correct name.can it be done?with javascript code maybe? thanks really for your time!!


rest service and compare value to db value

Posted: Tue Jan 13, 2015 4:21 am
by Yurii Orishchuk

Hi Karavidas,

In this case it's better to use server code.

So the workflow of the Server code will be:

  1. Get JS file from your source.

  2. Get other JS file from other source.

  3. Iterate through the first JS file object and set "name" for each needed item.(you can get it from 2nd js file).

  4. Return single response(that will contain all needed information).

  5. Then you can use this server code to get response with all need information.

    Regards.


rest service and compare value to db value

Posted: Tue Jan 13, 2015 1:08 pm
by karavidas jakolokoulos

is there any tutorial to help me write the javascript code?because,i m really dummy in javascript..


rest service and compare value to db value

Posted: Tue Jan 13, 2015 1:54 pm
by Ihor Didevych

Hi Karavidas

Let me know if this helps:
http://www.w3schools.com/js/


rest service and compare value to db value

Posted: Tue Jan 13, 2015 2:18 pm
by karavidas jakolokoulos

i m trying to do it..i still have problems though!i ll try more!but if you have more ideas about how i could solve the problem,tell me!!
really thanks for your help!!


rest service and compare value to db value

Posted: Wed Jan 14, 2015 2:26 am
by karavidas jakolokoulos

it didnt do the trick..sorry.
i m so confused..so if you can,just point me to the right way..i ve already shared my app with the support..
to be more specific so you could help me (i m really really confused right now) in short words,what i want to do is that:
i m getting data from here:
http://ekloges-prev.singularlogic.eu/...

as you pointed out (and thank you so so much for that) there are multiple .js files like this one: http://ekloges-prev.singularlogic.eu/...
which i have to use,to take data for every electoral distinct.
so the get syntax for one file is:
http://imageshack.com/a/img631/9677/L...
the test results:
http://imageshack.com/a/img538/1646/1...

the problem is that on responce data i just get the "party_id" as shown here:
http://imageshack.com/a/img901/7675/z...

the "party_name" are on a static file,as shown here:
http://imageshack.com/a/img538/3929/n...
and the .js exactly is this one:
http://ekloges-prev.singularlogic.eu/...

so what i want to do is to take from the first .js file the "party_id" and the other data,such as "votes" "percentage" etc and compare this "party_id" to the one from the second .js file (http://ekloges-prev.singularlogic.eu/...
) so it will return the "party_name" value,to the appropriate field of my app.

i tried like a million of things,but i was unlucky..nothing worked!
firstly,i cant import via a rest service,this second .js file,because it is a window.static one,and i get this error:
http://imagizer.imageshack.us/a/img53...

so my first big problem is how to somehow use the data of it!is there any way??i also tried with no luck to save it as external resourse.

after that,the second and last problem is what i ve described before,to compare these 2 files,and for every party_id to return the correct party_name..

the same thing happens also with the id's from the electoral distincts..

if you have any,any solution,please tell me..i spend like 10 hours every day,but still no luck..
really thanks for your time and your consideration!you are so kind and helpful!!


rest service and compare value to db value

Posted: Wed Jan 14, 2015 10:58 pm
by karavidas jakolokoulos

please confirm that my app is shared with the support,and also that you ve understand where the problem with my app is!


rest service and compare value to db value

Posted: Wed Jan 14, 2015 11:52 pm
by Yurii Orishchuk

Hi Karavidas,

Please give us your app name and describe how we can reproduce this issue in your app.

Also please specify how it should work in your app.

We will take a look.

Regards.


rest service and compare value to db value

Posted: Thu Jan 15, 2015 12:01 am
by karavidas jakolokoulos

my apps name is ekloges 2014.
i m trying to get data from a static js file as described above,but with no success.(i tried a million things).then (after i import data from the static js file) i want to compare the value returned from the mobilelabel106,to this static file and get the party_name.full details are on my previous post where i ve posted some screenshots to be more specific!!
really really thanks,if you could take a look it would be great!!


rest service and compare value to db value

Posted: Thu Jan 15, 2015 12:06 am
by karavidas jakolokoulos

i also tried that:
i copied some data from the static js file to my database.and then i tried by using database queries to get the appropriate value of field "onoma" which is name,by using the party_id "kwdikos" so it would return pasok for id=1,nd for id=2 etc..
the problem is that even if by using the query i didnt have more success..
maybe its a problem of my mapping?or i should do something with the "where" field??