org.deepamehta.plugins.wikidata
Class WikidataSearchPlugin

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by org.deepamehta.plugins.wikidata.WikidataSearchPlugin
All Implemented Interfaces:
PluginContext, PluginService, WikidataSearchService, org.osgi.framework.BundleActivator

public class WikidataSearchPlugin
extends PluginActivator
implements WikidataSearchService

A very basic plugin to search and explore wikidata. Allows to turn a \"Wikidata Search Result Entity\" (of type=property) into DeepaMehta 4 AssociationTypes.

Version:
0.0.3-SNAPSHOT
Author:
Malte Rei├čig ()

Field Summary
private  AccessControlService acService
           
private  String CHARSET
           
private  String DEEPAMEHTA_VERSION
           
private  String DM_WEBBROWSER_URL
           
private  boolean isInitialized
           
private  Logger log
           
private  String WD_CHECK_ENTITY_CLAIMS_ENDPOINT
           
private  String WD_ENTITY_CLAIM_EDGE
           
private  String WD_GET_ENTITY_ENDPOINT
           
private  String WD_LANGUAGE_DATA_URI_PREFIX
           
private  String WD_LANGUAGE_URI
           
private  String WD_SEARCH_BUCKET_URI
           
private  String WD_SEARCH_ENTITIES_ENDPOINT
           
private  String WD_SEARCH_ENTITIY_DATA_URI_PREFIX
           
private  String WD_SEARCH_ENTITY_ALIAS_URI
           
private  String WD_SEARCH_ENTITY_DESCR_URI
           
private  String WD_SEARCH_ENTITY_LABEL_URI
           
private  String WD_SEARCH_ENTITY_ORDINAL_NR
           
private  String WD_SEARCH_ENTITY_TYPE_ITEM
           
private  String WD_SEARCH_ENTITY_TYPE_PROPERTY
           
private  String WD_SEARCH_ENTITY_TYPE_URI
           
private  String WD_SEARCH_ENTITY_URI
           
private  String WD_SEARCH_QUERY_URI
           
private  String WD_TEXT_TYPE_URI
           
private  String WIKIDATA_ENTITY_URL_PREFIX
           
private  String WIKIDATA_PROPERTY_ENTITY_URL_PREFIX
           
private  String WIKIDATA_TYPE_SEARCH_VERSION
           
private  String WIKIMEDIA_COMMONS_MEDIA_FILE_URL_PREFIX
           
private  String WS_WIKIDATA_URI
           
 
Fields inherited from class de.deepamehta.core.osgi.PluginActivator
bundle, dms
 
Constructor Summary
WikidataSearchPlugin()
           
 
Method Summary
private  void assignToWikidataWorkspace(Topic topic)
           
private  boolean associationExists(String edge_type, Topic item, Topic user)
           
private  CompositeValueModel buildWikidataEntityModel(org.codehaus.jettison.json.JSONObject entity_response, String lang)
           
 Topic createWikidataAssociationType(long id, ClientState clientState)
          This method creates a DeepaMehta Association Type given a \"Wikidata Search Entity\" (of type=property).
private  Association createWikidataClaimEdge(String claim_guid, Topic one, Topic two, Topic property, ClientState clientState)
           
private  Topic createWikidataSearchEntity(org.codehaus.jettison.json.JSONObject entity_response, String lang, ClientState clientState)
           
 Topic getOrCreateWikidataEntity(String entityId, String language_code, ClientState clientState)
          This method gets (or creates) a \"Wikidata Search Entity\" (in DeepaMehta 4) by its ID (wikidata).
private  Topic getOrCreateWikidataText(String value, String lang, ClientState clientState)
           
 List<RelatedAssociation> getTopicRelatedAssociations(long topicId)
          This method retrieves all associated associations of type "Wikidata Claim" for any given \"Wikidata Search Entity\" (of type=property).
 Topic loadClaimsAndRelatedWikidataItems(long topicId, String language_option, ClientState clientState)
          This method loads all claims (with language specific values) for a wikidata-entity into DeepaMehta 4.
private  void processWikidataClaims(String json_result, Topic wikidataItem, String language_code, ClientState clientState)
           
private  void processWikidataEntitySearch(String json_result, CompositeValueModel search_bucket, String type, String lang)
           
 Topic searchWikidataEntity(String query, String lang, ClientState clientState, String type)
          This method searches all wikidata entities by text and the given language code.
 void serviceArrived(PluginService service)
          --- Implementing PluginService Interfaces to consume AccessControlService ---
 void serviceGone(PluginService service)
           
private  Topic updateWikidataEntity(Topic entity, org.codehaus.jettison.json.JSONObject entity_response, String lang, ClientState clientState)
           
 
Methods inherited from class de.deepamehta.core.osgi.PluginActivator
getBundleContext, getUri, init, postInstall, publishDirectory, setCoreService, shutdown, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private Logger log

DEEPAMEHTA_VERSION

private final String DEEPAMEHTA_VERSION
See Also:
Constant Field Values

WIKIDATA_TYPE_SEARCH_VERSION

private final String WIKIDATA_TYPE_SEARCH_VERSION
See Also:
Constant Field Values

CHARSET

private final String CHARSET
See Also:
Constant Field Values

DM_WEBBROWSER_URL

private final String DM_WEBBROWSER_URL
See Also:
Constant Field Values

WS_WIKIDATA_URI

private final String WS_WIKIDATA_URI
See Also:
Constant Field Values

WD_SEARCH_BUCKET_URI

private final String WD_SEARCH_BUCKET_URI
See Also:
Constant Field Values

WD_SEARCH_QUERY_URI

private final String WD_SEARCH_QUERY_URI
See Also:
Constant Field Values

WD_LANGUAGE_URI

private final String WD_LANGUAGE_URI
See Also:
Constant Field Values

WD_LANGUAGE_DATA_URI_PREFIX

private final String WD_LANGUAGE_DATA_URI_PREFIX
See Also:
Constant Field Values

WD_SEARCH_ENTITY_URI

private final String WD_SEARCH_ENTITY_URI
See Also:
Constant Field Values

WD_SEARCH_ENTITY_LABEL_URI

private final String WD_SEARCH_ENTITY_LABEL_URI
See Also:
Constant Field Values

WD_SEARCH_ENTITY_TYPE_URI

private final String WD_SEARCH_ENTITY_TYPE_URI
See Also:
Constant Field Values

WD_SEARCH_ENTITY_ORDINAL_NR

private final String WD_SEARCH_ENTITY_ORDINAL_NR
See Also:
Constant Field Values

WD_SEARCH_ENTITY_DESCR_URI

private final String WD_SEARCH_ENTITY_DESCR_URI
See Also:
Constant Field Values

WD_SEARCH_ENTITY_ALIAS_URI

private final String WD_SEARCH_ENTITY_ALIAS_URI
See Also:
Constant Field Values

WD_SEARCH_ENTITIY_DATA_URI_PREFIX

private final String WD_SEARCH_ENTITIY_DATA_URI_PREFIX
See Also:
Constant Field Values

WD_TEXT_TYPE_URI

private final String WD_TEXT_TYPE_URI
See Also:
Constant Field Values

WD_ENTITY_CLAIM_EDGE

private final String WD_ENTITY_CLAIM_EDGE
See Also:
Constant Field Values

WD_SEARCH_ENTITIES_ENDPOINT

private final String WD_SEARCH_ENTITIES_ENDPOINT
See Also:
Constant Field Values

WD_CHECK_ENTITY_CLAIMS_ENDPOINT

private final String WD_CHECK_ENTITY_CLAIMS_ENDPOINT
See Also:
Constant Field Values

WD_GET_ENTITY_ENDPOINT

private final String WD_GET_ENTITY_ENDPOINT
See Also:
Constant Field Values

WD_SEARCH_ENTITY_TYPE_PROPERTY

private final String WD_SEARCH_ENTITY_TYPE_PROPERTY
See Also:
Constant Field Values

WD_SEARCH_ENTITY_TYPE_ITEM

private final String WD_SEARCH_ENTITY_TYPE_ITEM
See Also:
Constant Field Values

WIKIDATA_ENTITY_URL_PREFIX

private final String WIKIDATA_ENTITY_URL_PREFIX
See Also:
Constant Field Values

WIKIDATA_PROPERTY_ENTITY_URL_PREFIX

private final String WIKIDATA_PROPERTY_ENTITY_URL_PREFIX
See Also:
Constant Field Values

WIKIMEDIA_COMMONS_MEDIA_FILE_URL_PREFIX

private final String WIKIMEDIA_COMMONS_MEDIA_FILE_URL_PREFIX
See Also:
Constant Field Values

isInitialized

private boolean isInitialized

acService

private AccessControlService acService
Constructor Detail

WikidataSearchPlugin

public WikidataSearchPlugin()
Method Detail

searchWikidataEntity

public Topic searchWikidataEntity(String query,
                                  String lang,
                                  @HeaderParam(value="Cookie")
                                  ClientState clientState,
                                  String type)
Description copied from interface: WikidataSearchService
This method searches all wikidata entities by text and the given language code.

Specified by:
searchWikidataEntity in interface WikidataSearchService

getOrCreateWikidataEntity

public Topic getOrCreateWikidataEntity(String entityId,
                                       String language_code,
                                       @HeaderParam(value="Cookie")
                                       ClientState clientState)
Description copied from interface: WikidataSearchService
This method gets (or creates) a \"Wikidata Search Entity\" (in DeepaMehta 4) by its ID (wikidata). Updates values of the given topic if this wikidata-entity was already imported before.

Specified by:
getOrCreateWikidataEntity in interface WikidataSearchService

loadClaimsAndRelatedWikidataItems

public Topic loadClaimsAndRelatedWikidataItems(long topicId,
                                               String language_option,
                                               @HeaderParam(value="Cookie")
                                               ClientState clientState)
Description copied from interface: WikidataSearchService
This method loads all claims (with language specific values) for a wikidata-entity into DeepaMehta 4.

Specified by:
loadClaimsAndRelatedWikidataItems in interface WikidataSearchService

createWikidataAssociationType

public Topic createWikidataAssociationType(long id,
                                           @HeaderParam(value="Cookie")
                                           ClientState clientState)
Description copied from interface: WikidataSearchService
This method creates a DeepaMehta Association Type given a \"Wikidata Search Entity\" (of type=property).

Specified by:
createWikidataAssociationType in interface WikidataSearchService

getTopicRelatedAssociations

public List<RelatedAssociation> getTopicRelatedAssociations(long topicId)
Description copied from interface: WikidataSearchService
This method retrieves all associated associations of type "Wikidata Claim" for any given \"Wikidata Search Entity\" (of type=property).

Specified by:
getTopicRelatedAssociations in interface WikidataSearchService

processWikidataEntitySearch

private void processWikidataEntitySearch(String json_result,
                                         CompositeValueModel search_bucket,
                                         String type,
                                         String lang)

createWikidataSearchEntity

private Topic createWikidataSearchEntity(org.codehaus.jettison.json.JSONObject entity_response,
                                         String lang,
                                         ClientState clientState)

updateWikidataEntity

private Topic updateWikidataEntity(Topic entity,
                                   org.codehaus.jettison.json.JSONObject entity_response,
                                   String lang,
                                   ClientState clientState)

buildWikidataEntityModel

private CompositeValueModel buildWikidataEntityModel(org.codehaus.jettison.json.JSONObject entity_response,
                                                     String lang)

processWikidataClaims

private void processWikidataClaims(String json_result,
                                   Topic wikidataItem,
                                   String language_code,
                                   ClientState clientState)

createWikidataClaimEdge

private Association createWikidataClaimEdge(String claim_guid,
                                            Topic one,
                                            Topic two,
                                            Topic property,
                                            ClientState clientState)

getOrCreateWikidataText

private Topic getOrCreateWikidataText(String value,
                                      String lang,
                                      ClientState clientState)

associationExists

private boolean associationExists(String edge_type,
                                  Topic item,
                                  Topic user)

assignToWikidataWorkspace

private void assignToWikidataWorkspace(Topic topic)

serviceArrived

public void serviceArrived(PluginService service)
--- Implementing PluginService Interfaces to consume AccessControlService ---

Specified by:
serviceArrived in interface PluginContext
Overrides:
serviceArrived in class PluginActivator

serviceGone

public void serviceGone(PluginService service)
Specified by:
serviceGone in interface PluginContext
Overrides:
serviceGone in class PluginActivator


Copyright © 2014. All Rights Reserved.