Search in sources :

Example 1 with NotaryGeneralView

use of net.cryptonomica.returns.NotaryGeneralView in project cryptonomica by Cryptonomica.

the class VisitorAPI method showAllNotaries.

@ApiMethod(name = "searchForNotaries", path = "searchForNotaries", httpMethod = ApiMethod.HttpMethod.POST)
public ArrayList<NotaryGeneralView> showAllNotaries(final User googleUser) throws Exception {
    // ensure authorization
    UserTools.ensureCryptonomicaRegisteredUser(googleUser);
    // 
    List<Notary> notaryList = ofy().load().type(Notary.class).list();
    // 
    ArrayList<NotaryGeneralView> notaryGeneralViewArrayList = new ArrayList<>();
    if (notaryList != null) {
        for (Notary notary : notaryList) {
            Key<CryptonomicaUser> notaryCUkey = Key.create(CryptonomicaUser.class, notary.getId());
            // 
            CryptonomicaUser notaryCryptonomicaUser = ofy().load().key(notaryCUkey).now();
            // 
            UserProfileGeneralView notaryUserProfileGeneralView = new UserProfileGeneralView(notaryCryptonomicaUser);
            // 
            notaryGeneralViewArrayList.add(new NotaryGeneralView(notaryUserProfileGeneralView, notary));
        }
    }
    // 
    LOG.warning("notaryGeneralViewArrayList: " + new Gson().toJson(notaryGeneralViewArrayList));
    // 
    return notaryGeneralViewArrayList;
}
Also used : UserProfileGeneralView(net.cryptonomica.returns.UserProfileGeneralView) ArrayList(java.util.ArrayList) Notary(net.cryptonomica.entities.Notary) Gson(com.google.gson.Gson) NotaryGeneralView(net.cryptonomica.returns.NotaryGeneralView) CryptonomicaUser(net.cryptonomica.entities.CryptonomicaUser) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Aggregations

ApiMethod (com.google.api.server.spi.config.ApiMethod)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1 CryptonomicaUser (net.cryptonomica.entities.CryptonomicaUser)1 Notary (net.cryptonomica.entities.Notary)1 NotaryGeneralView (net.cryptonomica.returns.NotaryGeneralView)1 UserProfileGeneralView (net.cryptonomica.returns.UserProfileGeneralView)1