I use Grails 2.0.0 in NetBeans with the Geolocation support plugin version 0.4
using this plugin, I can display the map with my position marker, but I get an exception when I try to calculate the distance between two positions:
No such property: GeoUtils for class: org.grails.plugin.geolocation.GeolocationService
This is a piece of my code:
Coordinates f = new Coordinates()
f.setAltitude(31.634227951365595)
f.setLongitude(-8.00504207611084)
Coordinates t = new Coordinates()
t.setAltitude(31.63271158235246)
t.setLongitude(-7.999967336654663)
GeoPosition positionFrom = new GeoPosition()
positionFrom.setCoords(coordinatesFrom)
GeoPosition p = new GeoPosition()
p.setCoords(coordinatesTo)
GeolocationService g = new GeolocationService()
double test = g.distance(positionFrom, positionTo)
The probleme is in grails-app/services/org/grails/plugin/geolocation/GeolocationService.groovy:
double distance(GeoPosition positionFrom, GeoPosition positionTo) {
LatLngTool.distance(**GeoUtils**.convertGeopositionToLatLng(positionFrom), GeoUtils.convertGeopositionToLatLng(positionTo), getLengthUnit())
}
The geolocation plugin is broken. Till the author fixes it, you may want to fork it yourself and fix it for your application
In GeolocationService.groovy import the GeoUtils class
import org.grails.plugin.geolocation.utils.GeoUtils
Then in BuildConfig.groovy, refer to this modified version instead,
grails.plugin.location.geolocation = "<local_path_to>/geolocation"
afaik, that should be enough to proceed.
Thinks Mr Aldrin for the response, really there is a lot of errors in the source code of this plugin I emailed the developer but he didn't answer me. but I could solve all of thos problemes and i can now use it.
If there is someone who needs help at this level, I can send to him the corrected version .. haj.abdel( at ) gmail
Related
I am trying to generate the SHA-1 hash of a string using the Web Crypto API. The code i am using to do this is pretty much the second example from the MDN
SubtleCrypto.digest() page.
async function getHash(value, algorithm = 'SHA-1') {
let msgBuffer = new TextEncoder('utf-8').encode(value);
let hashBuffer = await crypto.subtle.digest(algorithm, msgBuffer);
let hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
}
See this JSFiddle for a demo.
I am also using this TextEncoder Polyfill in Edge. It works fine in Firefox and Chrome, but in Microsoft Edge i just get the error message "SHA-1".
I couldn't find anything about this error. Does someone know what is going wrong? Is there a better way to do this?
"Edge does not support SHA1", try https://github.com/PeculiarVentures/webcrypto-liner?
I occure a problem which I do not understand. Following code does not work:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setLifecycleStatusToArchived();
accountingEntity.save(flush:true);
Where the method setLivecylceStatusToArchived looks like:
void setLifecycleStatusToArchived() {
this.lifecycleStatus = AccountingEntity.LIFECYCLE_ARCHIVED; //predefined static variable
this.considerForRankingJob = false;
this.dateArchived = new Date();
}
Problem is, that the entity is not updated.
No validation erros when I use accountingEntity.validate() in advance.
However, this code works:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setDateArchived(new Date());
accountingEntity.setConsiderForRankingJob(false);
accountingEntity.setLifecycleStatus(AccountingEntity.LIFECYCLE_ARCHIVED);
accountingEntity.save(flush:true);
The code did not work any more after update from Grails 3.2.9 to 3.3.0.RC1 (Gorm 6.1.5) unless I followed all the steps in the guide (http://docs.grails.org/3.3.x/guide/upgrading.html) and the rest of the code is working properly (also database accesses etc.)
Has anybody an idea? What the problem could be?
Thanks in advance and best regards!
The short answer is dirty checking. When you are setting properties inside the instance method Grails doesn't know they are dirty.
See the following github issue for how to resolve the problem:
https://github.com/grails/grails-data-mapping/issues/961
you have 2 options:
call markDirty every time you change an internal field. This will be
better for performance or as per
http://gorm.grails.org/latest/hibernate/manual/index.html#upgradeNotes
use
hibernateDirtyChecking: true
I am developing a mobile application using phonegap, Initially I have developed using WEBSQL but now I m planning to move it on INDEXDB. The problem is it does not have direct support on IOS , so on doing much R&D I came to know using IndexedDB Polyfil we can implement it on IOS too
http://blog.nparashuram.com/2012/10/indexeddb-example-on-cordova-phonegap.html
http://nparashuram.com/IndexedDBShim/
Can some please help me how to implement this as there are not enough documentation for this and I cannot figure out a any other solution / api except this
I have tested this on safari 5.1.7
Below is my code and Error Image
var request1 = indexedDB.open(dbName, 5);
request1.onsuccess = function (evt) {
db = request1.result;
var transaction = db.transaction(["AcceptedOrders"], "readwrite");
var objectStore = transaction.objectStore("AcceptedOrders");
for (var i in data) {
var request = objectStore.add(data[i]);
request.onsuccess = function (event) {
// alert("am again inserted")
// event.target.result == customerData[i].ssn;
};
}
};
request1.onerror = function (evt) {
alert("IndexedDB error: " + evt.target.errorCode);
};
Error Image
One blind guess
Maybe your dbName contains illegal characters for WebSQL database names. The polyfill doesn't translate your database names in any kind. So if you create a database called my-test, it would try to create a WebSQL database with the name my-test. This name is acceptable for an IndexedDB database, but in WebSQL you'll get in trouble because of the - character. So your database name has to match both, the IndexedDB and the WebSQL name conventions.
... otherwise use the debugger
You could set a break point onto your alert(...); line and use the debugger to look inside the evt object. This way you may get either more information about the error itself or more information to share with us.
To do so, enable the development menu in the Safari advanced settings, hit F10 and go to Developer > Start debugging JavaScript (something like that, my Safari is in a different language). Now open then "Scripts" tab in the developer window, select your script and set the break point by clicking on the line number. Reload the page and it should stop right in your error callback, where you can inspect the evt object.
If this doesn't help, you could get the non-minified version of the polyfill and try set some breakpoints around their open function to find the origin of this error.
You could try my open source library https://bitbucket.org/ytkyaw/ydn-db/wiki/Home. It works on iOS and Android.
We upgraded our jira to version 5.0.5 today, before we were running version 4.2.4. In that version we had made a custom release notes template that would also show all comments made on an issue. To do that we had to be able to get a CommentManager object. We did this like this:
#foreach ($issue in $issueType.issues)
#if($issueType.issues.size() > 0)
#set ($comments = $action.ComponentManager.CommentManager.getComments($issue))
#if ($comments)
#foreach ($comment in $comments)
...
That worked fine in JIRA 4.2.4 however it isn't working anymore in jira 5.0.5, does anyone know how i can get a CommentManager object again when creating a custom release notes template in JIRA 5.0.5 or how to get a CommentManager object some other way, without using $action for example?
In your vm template, write this:
#set ($componentAccessorClass = $constantsManager.getClass().getClassLoader().findClass('com.atlassian.jira.component.ComponentAccessor'))
#set ($componentAccessorConstructor = $componentAccessorClass.getConstructor())
#set ($componentAccessor = $componentAccessorConstructor.newInstance())
Now you have access to the Component Accessor which can get you pretty much anything you want, including the Comment Manager.
Now, all you have to do is call getCommentManager() on your Component Accessor variable.
#set($commentManager = $componentAccessor.getCommentManager() )
Hope that helps ! :)
JiraWebActionSupport has the following deprecated method that provided the component manager object.
#Deprecated
public ComponentManager getComponentManager()
{
return ComponentManager.getInstance();
}
and https://developer.atlassian.com/display/JIRADEV/Creating+a+Custom+Release+Notes+Template+Containing+Release+Comments
has some Velocity code but looking at the 5.0.1 source it looks like Velocity is no longer being used?
I would file an Improvement at https://jira.atlassian.com/browse/JRA to add a getCommentManager method to JiraWebActionSupport.java
this is the way i used in jira to get a componentmanager object, once you have the componentmanager object it's rather easy to do the rest:
#set ($componentManagerClass = $constantsManager.getClass().getClassLoader().findClass('com.atlassian.jira.ComponentManager'))
#set ($method = $componentManagerClass.getDeclaredMethod('getInstance', null))
#set ($componentManager = $method.invoke(null, null))
i'm using this solution now, and it can be rather helpfull to others to almost get any kind of class using the constantsmanager.
I'd like to get access to my currently running applications applicationDescriptor object. I want this so that I can get the current version number and, on the initial screen have a title like "MyApp Version x.x.x" where I get x.x.x from the ApplicationDescriptor.getVersion()
One way that I've found is to use:
ApplicationManager manager = ApplicationManager.getApplicationManager();
ApplicationDescriptor[] descriptors = manager.getVisibleApplications();
//Loop round descriptors then use...
ApplicationDescriptor myApp = manager.getProcessId(descriptors[x]);
Using the loop to check all applications seems a bit long winded to me, i'm hoping that there is an easier route.
Thanks
Got it:
ApplicationDescriptor.currentApplicationDescriptor().getVersion()