Improvements to Adapt sample server/client
[smartapi.git] / Examples / Python / AdaptDataService / SampleSearchClient.py
1 #!/usr/bin/python
2
3 from SmartAPI.agents.SearchAgent import SearchAgent
4
5 from SmartAPI.common.Tools import Tools
6 from SmartAPI.common.RESOURCE import RESOURCE
7
8 from SmartAPI.model.Activity import Activity
9 from SmartAPI.model.Condition import Condition
10 from SmartAPI.model.Entity import Entity
11
12
13 myIdentity = "http://adapt.asema.com/demos/python/datasourcesearch/"
14 adaptServiceIdentity = "http://adapt.asema.com"
15 registrationServerUri = "http://find.smart-api.io/smart/v1.0e1.0/access"
16 #registrationServerUri = "http://192.168.2.96:8080/smartapifind-core/smart/v1.0e1.0/access"
17
18
19 class SampleSearch(object):
20
21         def __init__(self):
22                 pass
23
24         def do(self):
25                 agent = SearchAgent(myIdentity)
26                 agent.setServerAddress(registrationServerUri)
27                 agent.setDebugMode(True)
28
29                 e = Entity()
30                 e.setServedBy(adaptServiceIdentity)
31                 agent.setEntity(e)
32                 
33                 result = agent.doSearch()
34                 
35                 if len(result) > 0:
36                         print "FOUND THE FOLLOWING:"
37                         for r in result:
38                                 r.turtlePrint()
39                 else:
40                         print "No results found."
41
42
43 def main():
44         s = SampleSearch()
45         s.do()
46
47
48 if __name__ == '__main__':
49         main()
50