vendredi 11 septembre 2015

How can I write this relatively simple criteria query involving three domains?

Just for background, let us have these three domain classes:

class Group {
    Long id
    Person person
}

class Person {
    Long id
    Country country
    String name
}

class Country {
    Long id
}

So, with these classes in mind, I am given a Group object's id as well as a Country object's id. I would like to get the list of Person objects based on these two.

It seems relatively simple, but I am new to criteria queries and so I am struggling to figure out what I am doing wrong. This is what I have so far:

def c = Group.createCriteria()
def names = c.list (order: "asc") {
    createAlias('person', 'p')
    createAlias('p.country', 'c')
    and {
        eq ('c.id', Long.valueOf(countryId))
        eq ('id', groupId)
    }
    projections {
        property('p.name')
    }
}

Of course, this is wrong as it is throwing errors. Can someone please let me know what I am doing wrong?

Thanks for your help!



via Chebli Mohamed

CSS Overflow in Chrome 45 and Edge

In MS Edge and Chrome 45, using overflow:auto on one of my site's DIVs hides all the contents. I can resolve this by switching to overflow:visible. But why are these two browsers rendering differently, and how can I avoid the problem in my CSS?



via Chebli Mohamed

How to call a ClearQuest REST API from Visual Studio (C# or VB.Net)

I am trying to find some C#/VB.Net code samples showing how to make ClearQuest Restful API calls.



via Chebli Mohamed

How to implement navigation controller/tab bar controller in React/Flux?

I'm creating a SPA mobile app using React. I'm wondering how I would create a navigation controller or a tab bar controller using the Flux way. Basically I'm wondering how I handle ownership of children and who/what handles the actual transitions.

Right now I have a navigationController component that has a push method to add pages to the stack and transition them in our out. All of this is stored in the state, and the parent component knows nothing about this.

For my tab bar controller, the parent component passes in some tabBar items with the children of the tabBar item being the content to show when the tab is active. The tab bar controller handles when a tab is active and what content to show based on the active tab. The parent doesn't know anything about which tab is active. the active tab is stored in the tab bar controller's state.

Stuff like this just doesn't seem to be easily implemented in Flux. How would I, from the parent, tell a navigation controller to add an element, and then handle the transition from within controller. Also, how would added pages to the controller be able to push new pages if they have to go all the way up to the root?

I guess my problem might be that I don't fully understand Flux.

Any help would be greatly appreciated.



via Chebli Mohamed

Tickspot API: Get token using jQuery ajax

I'm testing the API V2 of tickspot http://ift.tt/1K2gIFM but I'm having some troubles trying to get the token.

$.ajax({
    url: 'http://ift.tt/1O5MB41',
    type: 'GET',
    //jsonp: "callback",
    dataType: 'jsonp',
    crossDomain: true,
    beforeSend: function(xhr) {
        xhr.withCredentials = true;
        xhr.setRequestHeader ("Authorization", "Basic " + btoa(username+":"+password));
        xhr.setRequestHeader('UserAgent','Project (email@company.com)');
    }
})
.done(function(response) {
    callback(response);
})
.fail(function(response) {
    callback(response);
})
.always(function() {
    console.log("complete");
});

I have tried with https and http but I always receive 401 Unauthorized and my credentials are correct.

Hope you can help me.



via Chebli Mohamed

How to run node app behind proxy using Node as delegation container

All:

I am new to Node, say if I want to run an node js app to visit internet behind a proxy, but this app does not support proxy, I wonder how can I use node as its delegation app to get through the proxy?

Thanks



via Chebli Mohamed

Converting my response to JsonObject format

I am fetching LinkedIn profile information upon logging in with your LinkedIn account and trying to send it to my server so I can store it. The response comes back to me in the form of an ApiResponse.

public void onApiSuccess(ApiResponse apiResponse) {
...
serverInteractionManager.sendLinkedInData(dummyJson, PreferenceManager.getPreference("eventId"), PreferenceManager.getPreference("personId"));
...    
}

The ApiResponse class has a getResponseDataAsJSON() method but that returns a JSONObject type as opposed to the JsonObject that I need.

public Future<JsonObject> sendLinkedInData(JsonObject jsonObject, String eventId, String personId) {
        try {
            return sendRequest("api/event/" + eventId + "/signup/" + personId, "").setJsonObjectBody(jsonObject).asJsonObject().setCallback(new FutureCallback<JsonObject>() {
                @Override
                public void onCompleted(Exception e, JsonObject result) {
                }
            });
        } catch (Exception e) {
            return null;
        }
}

Above is the method that sends a post request to my server, where I want to store the LinkedIn information I get after login.
Is there any way to convert between these two types? or convert a String to JsonObject somehow? (I can parse the ApiResponse to a String). I tried using Gson to not much success but I'm not very experienced with it. Cheers!



via Chebli Mohamed