Search in sources :

Example 1 with SearchAccessor

use of com.pratilipi.data.SearchAccessor in project pratilipi by Pratilipi.

the class PratilipiDataUtil method _updatePratilipiSearchIndex.

private static void _updatePratilipiSearchIndex(List<Pratilipi> pratilipiList) throws InvalidArgumentException, UnexpectedServerException {
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
    List<PratilipiData> pratilipiDataList = new ArrayList<>(pratilipiList.size());
    for (Pratilipi pratilipi : pratilipiList) {
        if (pratilipi.getState() == PratilipiState.PUBLISHED) {
            Author author = dataAccessor.getAuthor(pratilipi.getAuthorId());
            pratilipiDataList.add(createPratilipiData(pratilipi, author, true));
        } else {
            searchAccessor.deletePratilipiDataIndex(pratilipi.getId());
        }
    }
    if (pratilipiDataList.size() > 0) {
        Map<PratilipiData, String> pratilipiDataKeywordsMap = new HashMap<>();
        for (PratilipiData pratilipiData : pratilipiDataList) pratilipiDataKeywordsMap.put(pratilipiData, getPratilipiKeywords(pratilipiData.getId()));
        searchAccessor.indexPratilipiDataList(pratilipiDataKeywordsMap);
    }
}
Also used : SearchAccessor(com.pratilipi.data.SearchAccessor) HashMap(java.util.HashMap) DataAccessor(com.pratilipi.data.DataAccessor) PratilipiData(com.pratilipi.data.client.PratilipiData) ArrayList(java.util.ArrayList) Author(com.pratilipi.data.type.Author) UserPratilipi(com.pratilipi.data.type.UserPratilipi) Pratilipi(com.pratilipi.data.type.Pratilipi)

Example 2 with SearchAccessor

use of com.pratilipi.data.SearchAccessor in project pratilipi by Pratilipi.

the class DataStoreUtil method main.

public static void main(String... args) throws IOException, UnexpectedServerException, InterruptedException, ParseException {
    RemoteApiOptions options = new RemoteApiOptions().server("m.gamma.pratilipi.com", 80).useServiceAccountCredential("prod-pratilipi@appspot.gserviceaccount.com", "PrivateKey.p12").remoteApiPath("/remote_api");
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);
    ObjectifyService.begin();
    Memcache memcache = DataAccessorFactory.getL2CacheAccessor();
    GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
    BlobAccessor blobAccessor = DataAccessorFactory.getBlobAccessor();
    DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
    // START
    // END
    installer.uninstall();
}
Also used : RemoteApiInstaller(com.google.appengine.tools.remoteapi.RemoteApiInstaller) SearchAccessor(com.pratilipi.data.SearchAccessor) GcsService(com.google.appengine.tools.cloudstorage.GcsService) DataAccessor(com.pratilipi.data.DataAccessor) DocAccessor(com.pratilipi.data.DocAccessor) RemoteApiOptions(com.google.appengine.tools.remoteapi.RemoteApiOptions) BlobAccessor(com.pratilipi.data.BlobAccessor) Memcache(com.pratilipi.data.Memcache)

Example 3 with SearchAccessor

use of com.pratilipi.data.SearchAccessor in project pratilipi by Pratilipi.

the class AuthorDataUtil method updateAuthorSearchIndex.

public static void updateAuthorSearchIndex(Long authorId) throws UnexpectedServerException {
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
    Author author = dataAccessor.getAuthor(authorId);
    if (author.getState() == AuthorState.ACTIVE) {
        User user = author.getUserId() == null ? null : dataAccessor.getUser(author.getUserId());
        searchAccessor.indexAuthorData(createAuthorData(author), UserDataUtil.createUserData(user));
    } else {
        searchAccessor.deleteAuthorDataIndex(authorId);
    }
}
Also used : SearchAccessor(com.pratilipi.data.SearchAccessor) User(com.pratilipi.data.type.User) DataAccessor(com.pratilipi.data.DataAccessor) Author(com.pratilipi.data.type.Author)

Aggregations

DataAccessor (com.pratilipi.data.DataAccessor)3 SearchAccessor (com.pratilipi.data.SearchAccessor)3 Author (com.pratilipi.data.type.Author)2 GcsService (com.google.appengine.tools.cloudstorage.GcsService)1 RemoteApiInstaller (com.google.appengine.tools.remoteapi.RemoteApiInstaller)1 RemoteApiOptions (com.google.appengine.tools.remoteapi.RemoteApiOptions)1 BlobAccessor (com.pratilipi.data.BlobAccessor)1 DocAccessor (com.pratilipi.data.DocAccessor)1 Memcache (com.pratilipi.data.Memcache)1 PratilipiData (com.pratilipi.data.client.PratilipiData)1 Pratilipi (com.pratilipi.data.type.Pratilipi)1 User (com.pratilipi.data.type.User)1 UserPratilipi (com.pratilipi.data.type.UserPratilipi)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1