This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.zxing.MultiFormatWriter | |
import com.google.zxing.client.j2se.MatrixToImageWriter | |
import com.google.zxing.common.BitMatrix | |
import com.google.zxing.BarcodeFormat | |
import com.google.zxing.EncodeHintType | |
/** | |
* @author Michael Astreiko | |
*/ | |
class BarCodeRendererService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BarcodeFormat format = BarcodeFormat.valueOf(params.format) | |
File file = File.createTempFile("temp-barcode", "png") | |
barCodeRendererService.renderImageToFile(file, params.data, getSize(params.width), getSize(params.height), format) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user = User.get(params.id) | |
render(contentType:'text/json'){ | |
user{ | |
username(user.username) | |
birthday(user.birthday) | |
firstName(user.firstName) | |
lastName(user.lastName) | |
city(user.city) | |
.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"/api/${domainInPlural}"(controller: 'apiJsonRest', action:'list') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list = { | |
def domainNameInPluralForm = params.domainInPlural | |
def domainName = retrieveDomainName(domainNameInPluralForm) | |
def entity = grailsApplication.getArtefacts("Domain").find { | |
it.getShortName() == domainName | |
}?.clazz | |
def result = entity.list(params) | |
def converter = [domainNameInPluralForm:result] as JSON | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleDomainClassMarshaller extends DomainClassMarshaller { | |
protected static final Log log = LogFactory.getLog(BaseDomainClassMarshaller.class) | |
protected ProxyHandler proxyHandler | |
private static List SKIPPED_FIELDS = Arrays.asList("lastUpdated", "dateCreated", "createdBy", "class", "id"); | |
public SimpleDomainClassMarshaller() { | |
this(false, new HibernateProxyHandler()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserClassMarshaller extends SimpleDomainClassMarshaller { | |
private Map ALTERNATIVE_NAMES = ["username":"screenName"] | |
protected List getSkippedFields() { | |
return ["password", "email", "enabled", "accountExpired", "accountLocked", | |
"passwordExpired", "securityQuestion", "securityAnswer"] | |
} | |
protected String getAlternativeName(String originalName){ | |
return ALTERNATIVE_NAMES[originalName] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSON.registerObjectMarshaller(new UserClassMarshaller(), 155) | |
JSON.registerObjectMarshaller(new SimpleDomainClassMarshaller(), 150) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
properties { | |
/** The maximum number of active connections that can be allocated from | |
* this pool at the same time, or zero for no limit. | |
* Make it '-1' to prevent performance problems with idle connections | |
*/ | |
maxActive = -1 | |
/** | |
* The maximum number of active connections that can remain idle in the | |
* pool, without extra ones being released, or zero for no limit. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double EARTH_RADIUS = 6371 | |
/** | |
* Calculate distance based on Haversine algorithmus | |
* (thanks to http://www.movable-type.co.uk/scripts/latlong.html) | |
* | |
* @param latitudeFrom | |
* @param longitudeFrom | |
* @param latitudeTo | |
* @param longitudeTo | |
* @return distance in Kilometers |
OlderNewer