当前位置: 首页>>代码示例>>Java>>正文


Java DatastoreServiceFactory.getDatastoreService方法代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService方法的典型用法代码示例。如果您正苦于以下问题:Java DatastoreServiceFactory.getDatastoreService方法的具体用法?Java DatastoreServiceFactory.getDatastoreService怎么用?Java DatastoreServiceFactory.getDatastoreService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.datastore.DatastoreServiceFactory的用法示例。


在下文中一共展示了DatastoreServiceFactory.getDatastoreService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws IOException {
	resp.setContentType("text/html");
	resp.getWriter().println("<html><body>");

	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Query query = new Query("SharedList");
	query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
	List<Entity> results = datastore.prepare(query).asList(
			FetchOptions.Builder.withDefaults());
	for (Entity entity : results) {
		String email = (String) entity.getProperty("email");
		String productID = (String) entity.getKey().getName();
		String productName = (String) entity.getProperty("productName");
		Date sharedDate = (Date) entity.getProperty("sharedDate");

		resp.getWriter().println(
				email + " shared <a href=\"http://www.amazon.com/dp/"
						+ productID + "\" target=\"_blank\">" + "<b>"
						+ productName + "</b></a>!<br>");
	}

	resp.getWriter().println("</body></html>");
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:26,代码来源:SharedlistServlet.java

示例2: saveFile

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
/**
 * Save Full File
 *
 * @param inputStream
 */
private static void saveFile(InputStream inputStream) {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Calendar time = Calendar.getInstance(TimeZone.getTimeZone("CET"));
    time.set(Calendar.HOUR_OF_DAY,0);
    time.set(Calendar.MINUTE,0);
    time.set(Calendar.SECOND,0);
    Date measuredAt = time.getTime();
    long millis = time.getTimeInMillis();
    //
    Entity entity = new Entity(ENTITY_TYPE_FICHEROS,millis);
    entity.setIndexedProperty("Date", measuredAt);
    entity.setUnindexedProperty("File", GlobalUtils.getString(inputStream));
    // Store
    datastore.put(entity);
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:21,代码来源:GetNewData.java

示例3: getHTML

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@GET
@Produces(MediaType.TEXT_XML)
public WishlistProduct getHTML() {
	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	try {
		Key entKey = KeyFactory.createKey(email, productID);
		Entity entity = datastore.get(entKey);
		String productName = (String) entity.getProperty("productName");
		double currentPrice = (double) entity.getProperty("currentPrice");
		double lowestPrice = (double) entity.getProperty("lowestPrice");
		Date lowestDate = (Date) entity.getProperty("lowestDate");
		return new WishlistProduct(productID, productName, currentPrice,
				lowestPrice, lowestDate);
	} catch (EntityNotFoundException e) {
		throw new RuntimeException("GET: Wishlist with " + productID
				+ " not found.");
	}
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:20,代码来源:WishlistProductResource.java

示例4: get

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public WishlistProduct get() {
	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	try {
		Key entKey = KeyFactory.createKey(email, productID);
		Entity entity = datastore.get(entKey);
		String productName = (String) entity.getProperty("productName");
		double currentPrice = (double) entity.getProperty("currentPrice");
		double lowestPrice = (double) entity.getProperty("lowestPrice");
		Date lowestDate = (Date) entity.getProperty("lowestDate");
		return new WishlistProduct(productID, productName, currentPrice,
				lowestPrice, lowestDate);
	} catch (EntityNotFoundException e) {
		throw new RuntimeException("GET: Wishlist with " + productID
				+ " not found.");
	}
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:20,代码来源:WishlistProductResource.java

示例5: getEntities

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<SharedProduct> getEntities() {
	List<SharedProduct> list = new ArrayList<SharedProduct>();
	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Query query = new Query("SharedList");
	query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
	List<Entity> results = datastore.prepare(query).asList(
			FetchOptions.Builder.withDefaults());
	for (Entity entity : results) {
		String email = (String) entity.getProperty("email");
		String productID = (String) entity.getKey().getName();
		String productName = (String) entity.getProperty("productName");
		Date sharedDate = (Date) entity.getProperty("sharedDate");

		list.add(new SharedProduct(email, productID, productName,
				sharedDate));
	}

	return list;
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:23,代码来源:Sharedlist.java

示例6: testJobIdAndNumJobs_fails

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@Test
public void testJobIdAndNumJobs_fails() throws Exception {
  action = new MapreduceEntityCleanupAction(
      Optional.of("jobid"),
      Optional.empty(), // jobName
      Optional.of(1), // numJobsToDelete
      Optional.empty(), // daysOld
      Optional.empty(), // force
      mapreduceEntityCleanupUtil,
      clock,
      DatastoreServiceFactory.getDatastoreService(),
      response);

  action.run();

  assertThat(response.getStatus()).isEqualTo(SC_BAD_REQUEST);
  assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
  assertThat(response.getPayload())
      .isEqualTo("Do not specify both a job ID and a number of jobs to delete");
  assertNumMapreducesAndShardedJobs(0, 0);
}
 
开发者ID:google,项目名称:nomulus,代码行数:22,代码来源:MapreduceEntityCleanupActionTest.java

示例7: main

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  String serverString = args[0];
  RemoteApiOptions options;
  if (serverString.equals("localhost")) {
    options = new RemoteApiOptions().server(serverString,
      8080).useDevelopmentServerCredential();
  } else {
    options = new RemoteApiOptions().server(serverString,
      443).useApplicationDefaultCredential();
  }
  RemoteApiInstaller installer = new RemoteApiInstaller();
  installer.install(options);
  try {
    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    System.out.println("Key of new entity is " + ds.put(new Entity("Hello Remote API!")));
  } finally {
    installer.uninstall();
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:20,代码来源:RemoteApiExample.java

示例8: setUp

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {

  MockitoAnnotations.initMocks(this);
  helper.setUp();
  ds = DatastoreServiceFactory.getDatastoreService();

  //  Set up some fake HTTP requests
  when(mockRequest.getRequestURI()).thenReturn(FAKE_URL);
  when(mockRequest.getParameter("guestbookName")).thenReturn("default");
  when(mockRequest.getParameter("content")).thenReturn(testPhrase);

  stringWriter = new StringWriter();
  when(mockResponse.getWriter()).thenReturn(new PrintWriter(stringWriter));

  servletUnderTest = new SignGuestbookServlet();

  ObjectifyService.register(Guestbook.class);
  ObjectifyService.register(Greeting.class);

  closeable = ObjectifyService.begin();

  cleanDatastore(ds, "default");
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:25,代码来源:SignGuestbookServletTest.java

示例9: doPost

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  UserService userService = UserServiceFactory.getUserService();
  User user = userService.getCurrentUser(); 

  String guestbookName = req.getParameter("guestbookName");
  Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName);
  String content = req.getParameter("content");
  Date date = new Date();
  Entity greeting = new Entity("Greeting", guestbookKey);
  greeting.setProperty("user", user);
  greeting.setProperty("date", date);
  greeting.setProperty("content", content);

  DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
  datastore.put(greeting);

  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 
开发者ID:raghu-sannlingappa,项目名称:push-to-delploy,代码行数:21,代码来源:SignGuestbookServlet.java

示例10: getLastStatus

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
private ArrayList<Medicion> getLastStatus(int amountData) {
    // Poner Key estacion + hora_muestra
    Calendar calendarTwoAgo = Calendar.getInstance(TimeZone.getTimeZone("CET"));
    calendarTwoAgo.add(Calendar.DATE, -3);
    Date dateTwoAgo = calendarTwoAgo.getTime();

    // Prepare
    Query.Filter keyFilter = new Query.FilterPredicate(PROPERTY_MEASURE_DATE, Query.FilterOperator.GREATER_THAN, dateTwoAgo);
    Query.Filter no2Filter = new Query.FilterPredicate(PROPERTY_COMPUESTO, Query.FilterOperator.EQUAL, NO2.name());
    List<Query.Filter> filterList = new ArrayList<>();
    filterList.add(keyFilter);
    filterList.add(no2Filter);
    Query.Filter filter = new Query.CompositeFilter(Query.CompositeFilterOperator.AND, filterList);
    Query query = new Query(ENTITY_TYPE_MEDIDAS)
            .setFilter(filter)
            .addSort(PROPERTY_MEASURE_DATE
                    , Query.SortDirection.DESCENDING);

    // Query
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    PreparedQuery pq = datastore.prepare(query);
    // Get results

    List<com.google.appengine.api.datastore.Entity> resultList = pq.asList(FetchOptions.Builder.withLimit(amountData));
    ArrayList<Medicion> result = new ArrayList<>();
    if (resultList.size()!=0) {
        mLogger.info("Watching " + resultList.size() + " last values of ESTADO");
        for (com.google.appengine.api.datastore.Entity item : resultList){
            result.add(new Medicion((Date) item.getProperty(PROPERTY_MEASURE_DATE), (String) item.getProperty(PROPERTY_AVISO), (String) item.getProperty(PROPERTY_AVISO_STATE), (String) item.getProperty(PREPERTY_AVISO_MAX_TODAY), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TODAY), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW),  (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW_MANUAL) ,isPureMadrid()));
        }
    } else {
        // No hay datos
        mLogger.info("No previous values for ESTADO");
    }
    return result;
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:37,代码来源:GetNewData.java

示例11: getKey

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
/**
  * Gets the access key.
  */
 protected String getKey() {
     com.google.appengine.api.datastore.DatastoreService datastore = DatastoreServiceFactory
             .getDatastoreService();
     Key key = KeyFactory.createKey(ENTITY_KIND, ENTITY_KEY);
     String apiKey = "";
     try {
         Entity entity = datastore.get(key);
         apiKey = (String) entity.getProperty(ACCESS_KEY_FIELD);
     } catch (EntityNotFoundException e) {
         mLogger.severe("Exception will retrieving the API Key"
                 + e.toString());
     }
     return apiKey;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:18,代码来源:ApiKeyInitializer.java

示例12: listRawEntity

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
public Iterable<Entity> listRawEntity(Query q, Boolean returnKeysOnly) {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    if (returnKeysOnly) {
        q.setKeysOnly();
    }
    PreparedQuery pq = datastore.prepare(q);
    return pq.asIterable();
}
 
开发者ID:deniotokiari,项目名称:training-epam-2016,代码行数:9,代码来源:StoreServlet.java

示例13: deleteAllObjects

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
public void deleteAllObjects(Query query){
    final DatastoreService dss=DatastoreServiceFactory.getDatastoreService();
    final ArrayList<Key> keys=new ArrayList<>();
    for (  final Entity entity : dss.prepare(query).asIterable(FetchOptions.Builder.withLimit(100000))) {
        keys.add(entity.getKey());
    }
    dss.delete(keys);
}
 
开发者ID:deniotokiari,项目名称:training-epam-2016,代码行数:9,代码来源:StoreServlet.java

示例14: provideDatastore

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@Provides
DatastoreService provideDatastore(@DatastoreTimeoutMillis long datastoreTimeoutMillis) {
  return DatastoreServiceFactory.getDatastoreService(DatastoreServiceConfig.Builder
      .withDeadline(datastoreTimeoutMillis * 1000.0)
      .implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.NONE)
      .readPolicy(new ReadPolicy(ReadPolicy.Consistency.STRONG)));
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:8,代码来源:WalkaroundServerModule.java

示例15: getEntitiesBrowser

import com.google.appengine.api.datastore.DatastoreServiceFactory; //导入方法依赖的package包/类
@GET
@Produces(MediaType.TEXT_XML)
public List<WishlistProduct> getEntitiesBrowser() {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return null;
	}

	List<WishlistProduct> list = new ArrayList<WishlistProduct>();
	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Query query = new Query(user.getEmail());
	query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING);
	List<Entity> results = datastore.prepare(query).asList(
			FetchOptions.Builder.withDefaults());
	for (Entity entity : results) {
		String productID = (String) entity.getKey().getName();
		String productName = (String) entity.getProperty("productName");
		double currentPrice = (double) entity.getProperty("currentPrice");
		double lowestPrice = (double) entity.getProperty("lowestPrice");
		Date lowestDate = (Date) entity.getProperty("lowestDate");
		list.add(new WishlistProduct(productID, productName, currentPrice,
				lowestPrice, lowestDate));
	}

	return list;
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:30,代码来源:Wishlist.java


注:本文中的com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。