SlideShare a Scribd company logo
1 of 3
Data Store
(Google App Engine)

          José Luis Santos
 joseluis.santos@cs.kuleuven.be
Servlet
DatastoreServicedatastore = DatastoreServiceFactory.getDatastoreService();

Entity person = new Entity("Person", "test");
person.setUnindexedProperty("name", "TestUser"); //Unindexed properties for these properties that you will
not filter on

Entity weddingPhoto = new Entity("Photo", person.getKey()); // We link this Entity to another (Foreign key)
weddingPhoto.setProperty("imageUrl", "http://scm-l3.technorati.com/11/02/05/25749/marriage.jpg");
weddingPhoto.setProperty("date", new Date());

Entity weddingVideo = new Entity("Video", person.getKey()); // We link this Entity to another (Foreign key)
weddingVideo.setProperty("videoUrl", "http://www.criticallayouts.com/images/rsgallery/original/just-
married-cans-ag1.gif");
weddingVideo.setUnindexedProperty("date", new Date());

datastore.put(person);
datastore.put(weddingPhoto);
datastore.put(weddingVideo);

req.setAttribute("Key", person.getKey()); //Sending an object to a jsp file
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/store.jsp");
dispatcher.forward(req,resp);
JSP
DatastoreServicedatastore = DatastoreServiceFactory.getDatastoreService();
Key key = (Key)request.getAttribute("Key"); //We get an object not only an String
if (key != null){
Query userMediaQuery = new Query();
userMediaQuery.setAncestor(key);

// Ancestor queries return ancestors by default. This filter excludes the ancestor from query results.
userMediaQuery.addFilter(Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.GREATER_THAN, key);

// Returns both weddingPhoto and weddingVideo even though they are different entity kinds.
List<Entity> results = datastore.prepare(userMediaQuery).asList( FetchOptions.Builder.withDefaults());

for (inti=0;i<results.size();i++){
if (results.get(i).getKind().compareTo("Video")==0){%>
This is a photo:<br/><imgsrc="<%=results.get(i).getProperty("videoUrl")%>"></img><br/>
<% }else if (results.get(i).getKind().compareTo("Photo")==0){%>
This is a video:<br/><imgsrc="<%=results.get(i).getProperty("imageUrl")%>"></img><br/>
<% }%>

More Related Content

Viewers also liked

Data Collection-Primary & Secondary
Data Collection-Primary & SecondaryData Collection-Primary & Secondary
Data Collection-Primary & Secondary
Prathamesh Parab
 

Viewers also liked (9)

Bottom up & top down tutorial 2
Bottom up & top down tutorial 2Bottom up & top down tutorial 2
Bottom up & top down tutorial 2
 
Qualitative data analysis: many approaches to understand user insights
Qualitative data analysis: many approaches to understand user insightsQualitative data analysis: many approaches to understand user insights
Qualitative data analysis: many approaches to understand user insights
 
Presentation on Database management system
Presentation on Database management systemPresentation on Database management system
Presentation on Database management system
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Teaching approaches
Teaching approachesTeaching approaches
Teaching approaches
 
Qualitative Research
Qualitative ResearchQualitative Research
Qualitative Research
 
Chapter 9-METHODS OF DATA COLLECTION
Chapter 9-METHODS OF DATA COLLECTIONChapter 9-METHODS OF DATA COLLECTION
Chapter 9-METHODS OF DATA COLLECTION
 
Data Collection-Primary & Secondary
Data Collection-Primary & SecondaryData Collection-Primary & Secondary
Data Collection-Primary & Secondary
 
Qualitative data analysis
Qualitative data analysisQualitative data analysis
Qualitative data analysis
 

Similar to Datastore

Parse - a mobile backend platform
Parse - a mobile backend platformParse - a mobile backend platform
Parse - a mobile backend platform
Carlotta Tatti
 

Similar to Datastore (8)

Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Try!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftTry!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is Swift
 
Creating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdfCreating a Facebook Clone - Part XXXVII.pdf
Creating a Facebook Clone - Part XXXVII.pdf
 
Parse - a mobile backend platform
Parse - a mobile backend platformParse - a mobile backend platform
Parse - a mobile backend platform
 
Desenvolvendo Aplicativos Sociais com Rails 3
Desenvolvendo Aplicativos Sociais com Rails 3Desenvolvendo Aplicativos Sociais com Rails 3
Desenvolvendo Aplicativos Sociais com Rails 3
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
 
Creating a Facebook Clone - Part X - Transcript.pdf
Creating a Facebook Clone - Part X - Transcript.pdfCreating a Facebook Clone - Part X - Transcript.pdf
Creating a Facebook Clone - Part X - Transcript.pdf
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 

More from Jose Luis Santos Odriozola

Public PhD defense
Public PhD defensePublic PhD defense
Public PhD defense
Jose Luis Santos Odriozola
 
LAK 14 presentation - Success, activity and drop-outs in MOOCs
LAK 14 presentation - Success, activity and drop-outs in MOOCsLAK 14 presentation - Success, activity and drop-outs in MOOCs
LAK 14 presentation - Success, activity and drop-outs in MOOCs
Jose Luis Santos Odriozola
 

More from Jose Luis Santos Odriozola (18)

Workshop - Functional Testing - Lessons Learned
Workshop - Functional Testing - Lessons LearnedWorkshop - Functional Testing - Lessons Learned
Workshop - Functional Testing - Lessons Learned
 
DiD at the XPDays Benelux
DiD at the XPDays BeneluxDiD at the XPDays Benelux
DiD at the XPDays Benelux
 
Public PhD defense
Public PhD defensePublic PhD defense
Public PhD defense
 
LAK 14 presentation - Success, activity and drop-outs in MOOCs
LAK 14 presentation - Success, activity and drop-outs in MOOCsLAK 14 presentation - Success, activity and drop-outs in MOOCs
LAK 14 presentation - Success, activity and drop-outs in MOOCs
 
Seminar at UC3M Madrid
Seminar at UC3M MadridSeminar at UC3M Madrid
Seminar at UC3M Madrid
 
20131007 peno3 sessie3_sven_jose
20131007 peno3 sessie3_sven_jose20131007 peno3 sessie3_sven_jose
20131007 peno3 sessie3_sven_jose
 
20130918 ectel cyprus_jose
20130918 ectel cyprus_jose20130918 ectel cyprus_jose
20130918 ectel cyprus_jose
 
Presentation @LAK13
Presentation @LAK13 Presentation @LAK13
Presentation @LAK13
 
WeSPOT presentation with Alacatel-lucent
WeSPOT presentation with Alacatel-lucent WeSPOT presentation with Alacatel-lucent
WeSPOT presentation with Alacatel-lucent
 
Final presentación
Final presentaciónFinal presentación
Final presentación
 
Peno 3 Google App Engine introduction
Peno 3 Google App Engine introductionPeno 3 Google App Engine introduction
Peno 3 Google App Engine introduction
 
Peno3 instructions
Peno3 instructionsPeno3 instructions
Peno3 instructions
 
Learning Analytics MUME 2012
Learning Analytics MUME 2012Learning Analytics MUME 2012
Learning Analytics MUME 2012
 
Empowering students to reflect on their activity with StepUp!
Empowering students to reflect on their activity with StepUp!Empowering students to reflect on their activity with StepUp!
Empowering students to reflect on their activity with StepUp!
 
Lak12 jlsantos-v2
Lak12 jlsantos-v2Lak12 jlsantos-v2
Lak12 jlsantos-v2
 
Project management
Project managementProject management
Project management
 
Quantified learning
Quantified learningQuantified learning
Quantified learning
 
Registry slides for Se@m Workshop
Registry slides for Se@m Workshop Registry slides for Se@m Workshop
Registry slides for Se@m Workshop
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

Datastore

  • 1. Data Store (Google App Engine) José Luis Santos joseluis.santos@cs.kuleuven.be
  • 2. Servlet DatastoreServicedatastore = DatastoreServiceFactory.getDatastoreService(); Entity person = new Entity("Person", "test"); person.setUnindexedProperty("name", "TestUser"); //Unindexed properties for these properties that you will not filter on Entity weddingPhoto = new Entity("Photo", person.getKey()); // We link this Entity to another (Foreign key) weddingPhoto.setProperty("imageUrl", "http://scm-l3.technorati.com/11/02/05/25749/marriage.jpg"); weddingPhoto.setProperty("date", new Date()); Entity weddingVideo = new Entity("Video", person.getKey()); // We link this Entity to another (Foreign key) weddingVideo.setProperty("videoUrl", "http://www.criticallayouts.com/images/rsgallery/original/just- married-cans-ag1.gif"); weddingVideo.setUnindexedProperty("date", new Date()); datastore.put(person); datastore.put(weddingPhoto); datastore.put(weddingVideo); req.setAttribute("Key", person.getKey()); //Sending an object to a jsp file RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/store.jsp"); dispatcher.forward(req,resp);
  • 3. JSP DatastoreServicedatastore = DatastoreServiceFactory.getDatastoreService(); Key key = (Key)request.getAttribute("Key"); //We get an object not only an String if (key != null){ Query userMediaQuery = new Query(); userMediaQuery.setAncestor(key); // Ancestor queries return ancestors by default. This filter excludes the ancestor from query results. userMediaQuery.addFilter(Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.GREATER_THAN, key); // Returns both weddingPhoto and weddingVideo even though they are different entity kinds. List<Entity> results = datastore.prepare(userMediaQuery).asList( FetchOptions.Builder.withDefaults()); for (inti=0;i<results.size();i++){ if (results.get(i).getKind().compareTo("Video")==0){%> This is a photo:<br/><imgsrc="<%=results.get(i).getProperty("videoUrl")%>"></img><br/> <% }else if (results.get(i).getKind().compareTo("Photo")==0){%> This is a video:<br/><imgsrc="<%=results.get(i).getProperty("imageUrl")%>"></img><br/> <% }%>