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


Java KeyFactory.keyToString方法代码示例

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


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

示例1: toJson

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
/**
* Returns the customer profile information as a JSON object.
* @return the customer profile in JSON format
*/
  @Get("json")
  public CustomerSimple toJson() {
  	
  	String queryInfo = (String) getRequest().getAttributes()
              .get("queryinfo");
          
      char searchBy = queryInfo.charAt(0);
      String searchEmailString = queryInfo.substring(2);
      Email searchEmail = new Email(searchEmailString);
      
      log.info("Query: " + searchBy + "=" + searchEmailString);
  	
      Customer customer = CustomerManager.getCustomer(searchEmail);
      CustomerSimple customerSimple = new CustomerSimple(KeyFactory.keyToString(customer.getKey()),
      		customer.getCustomerName(), customer.getCustomerPhone(), customer.getCustomerGenderString(),
      		customer.getCustomerAddress());
      
      return customerSimple;
  }
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:24,代码来源:CustomerProfileResource.java

示例2: keyToString_getsPerson

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
@Test
public void keyToString_getsPerson() throws Exception {
  Entity p = new Entity("Person");
  p.setProperty("relationship", "Me");
  datastore.put(p);
  Key k = p.getKey();

  // [START generating_keys_3]
  String personKeyStr = KeyFactory.keyToString(k);

  // Some time later (for example, after using personKeyStr in a link).
  Key personKey = KeyFactory.stringToKey(personKeyStr);
  Entity person = datastore.get(personKey);
  // [END generating_keys_3]

  assertThat(personKey).isEqualTo(k);
  assertThat((String) person.getProperty("relationship"))
      .named("person.relationship")
      .isEqualTo("Me");
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:21,代码来源:EntitiesTest.java

示例3: ShortTextDataStore

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
public ShortTextDataStore(Entity textEntity) {
    keyString = KeyFactory.keyToString(textEntity.getKey());
    text = textToString(textEntity.getProperty("rawText"));
    if (text.length() > 300) {
        text = text.substring(0, 300) + " ...";
    }
    date = dateFormatter((Date) textEntity.getProperty("date"));
    keywords = new KnowledgeQuery(textEntity.getKey()).getTop3KeyWords();
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:10,代码来源:ShortTextDataStore.java

示例4: TextDataStore

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
public TextDataStore(Entity textEntity,
                     List<KnowledgeNodeDataStore> keywords,
                     List<List<KnowledgeNodeDataStore>>
                             knowledgeNodeDataStoreLst,
                     List<AnnotatedSentence> annotatedSentenceLst,
                     int limit) {
    super("Text");
    keyString = KeyFactory.keyToString(textEntity.getKey());
    text = textToString(textEntity.getProperty("rawText"));
    type = (int) (long) textEntity.getProperty("type");
    this.keywords = keywords;
    knowledgeNodeDataStoreList = knowledgeNodeDataStoreLst;
    annotatedSentenceList = annotatedSentenceLst;
    this.limit = limit;
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:16,代码来源:TextDataStore.java

示例5: createFromRaw

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
/**
 * Returns a new mutation entity created from a raw Datastore Entity instance.
 *
 * <p>The mutation key is generated deterministically from the {@code entity} key. The Entity
 * itself is serialized to bytes and stored within the returned mutation.
 */
@VisibleForTesting
public static CommitLogMutation createFromRaw(
    Key<CommitLogManifest> parent,
    com.google.appengine.api.datastore.Entity rawEntity) {
  CommitLogMutation instance = new CommitLogMutation();
  instance.parent = checkNotNull(parent);
  // Creates a web-safe key string.
  instance.entityKey = KeyFactory.keyToString(rawEntity.getKey());
  instance.entityProtoBytes = convertToPb(rawEntity).toByteArray();
  return instance;
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:CommitLogMutation.java

示例6: test_deleteSingleRawEntitySuccessfully

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
@Test
public void test_deleteSingleRawEntitySuccessfully() throws Exception {
  Entity entity = new Entity("single", "raw");
  getDatastoreService().put(entity);
  action.rawKeys = KeyFactory.keyToString(entity.getKey());
  action.run();
  assertThat(response.getPayload())
      .isEqualTo("Deleted 1 raw entities and 0 registered entities");
}
 
开发者ID:google,项目名称:nomulus,代码行数:10,代码来源:DeleteEntityActionTest.java

示例7: test_deleteSingleRegisteredEntitySuccessfully

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
@Test
public void test_deleteSingleRegisteredEntitySuccessfully() throws Exception {
  ReservedList ofyEntity = new ReservedList.Builder().setName("foo").build();
  ofy().saveWithoutBackup().entity(ofyEntity).now();
  action.rawKeys = KeyFactory.keyToString(create(ofyEntity).getRaw());
  action.run();
  assertThat(response.getPayload())
      .isEqualTo("Deleted 0 raw entities and 1 registered entities");
}
 
开发者ID:google,项目名称:nomulus,代码行数:10,代码来源:DeleteEntityActionTest.java

示例8: test_deleteOneRawEntityAndOneRegisteredEntitySuccessfully

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
@Test
public void test_deleteOneRawEntityAndOneRegisteredEntitySuccessfully() throws Exception {
  Entity entity = new Entity("first", "raw");
  getDatastoreService().put(entity);
  String rawKey = KeyFactory.keyToString(entity.getKey());
  ReservedList ofyEntity = new ReservedList.Builder().setName("registered").build();
  ofy().saveWithoutBackup().entity(ofyEntity).now();
  String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
  action.rawKeys = String.format("%s,%s", rawKey, ofyKey);
  action.run();
  assertThat(response.getPayload())
      .isEqualTo("Deleted 1 raw entities and 1 registered entities");
}
 
开发者ID:google,项目名称:nomulus,代码行数:14,代码来源:DeleteEntityActionTest.java

示例9: test_deleteNonExistentEntityRepliesWithError

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
@Test
public void test_deleteNonExistentEntityRepliesWithError() throws Exception {
  Entity entity = new Entity("not", "here");
  String rawKey = KeyFactory.keyToString(entity.getKey());
  action.rawKeys = rawKey;
  BadRequestException thrown = expectThrows(BadRequestException.class, action::run);
  assertThat(thrown).hasMessageThat().contains("Could not find entity with key " + rawKey);
}
 
开发者ID:google,项目名称:nomulus,代码行数:9,代码来源:DeleteEntityActionTest.java

示例10: toJson

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
/**
* Returns the System table instance as a JSON object.
* @return The instance of the System object in JSON format
*/
  @Get("json")
  public SystemSimple toJson() {
      
  	// Get Station Versions
  	List<Station> stations = StationManager.getAllStations();
  	ArrayList<StationVersions> stationVersionList = new ArrayList<StationVersions>();
  	for (Station station : stations) {
  		List<Channel> channels = ChannelManager.getStationChannels(station.getKey());
  		
  		ArrayList<ChannelVersions> channelVersionList = new ArrayList<ChannelVersions>();
  		for (Channel channel : channels) {
  			ChannelVersions channelVersions = new ChannelVersions(
  					KeyFactory.keyToString(channel.getKey()),
  					channel.getProgramVersion());
  			channelVersionList.add(channelVersions);
  		}
  		
          StationVersions stationVersions = new StationVersions(
          		KeyFactory.keyToString(station.getKey()),
          		station.getPlaylistVersion(),
          		station.getStationImageVersion(),
          		station.getStationAudioVersion(),
          		channelVersionList);
          stationVersionList.add(stationVersions);
  	}
  	
      System system = SystemManager.getSystem();
      SystemSimple systemSimple = new SystemSimple(
      		system.getKey(),
      		system.getStationListVersion(),
      		system.getStationTypeListVersion(),
      		system.getMusicLibraryVersion(),
      		system.getOldestAppVersionSupportedString() != null ? 
      				system.getOldestAppVersionSupportedString() : "",
      		stationVersionList
      		);
      return systemSimple;
  }
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:43,代码来源:SystemResource.java

示例11: doGet

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
	
	// Check that an actual user is carrying out the action
	HttpSession session = req.getSession(true);
    User user = (User) session.getAttribute("user");
    if (user == null || user.getUserType() != User.Type.STATION) {
    	resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
        return;
    }
	
    // Lets check the action required by the jsp
    String action = req.getParameter("action");

    if (action.equals("delete")) {
    	
    	String type = req.getParameter("type");
    	
    	// Key of object to delete
    	Key key = KeyFactory.stringToKey(req.getParameter("k"));

    	String redirectURL = "?msg=success&action=" + action;
    	
        // Secondary Tracks
        if (type.equalsIgnoreCase("st")) {
        	SecondaryTrackManager.deleteSecondaryTrack(key);
        	
        	redirectURL = editProgramJSP + redirectURL + "&k=" + 
        			KeyFactory.keyToString(key.getParent());
        }
        // Slides
        else if (type.equalsIgnoreCase("slide")) {
        	SlideManager.deleteSlide(key);
        	
        	redirectURL = editProgramJSP + redirectURL + "&k=" + 
        			KeyFactory.keyToString(key.getParent());
        }
        else {
	    	resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
         		"Invalid type.");
	    	return;
        }
        
        // If success
        resp.sendRedirect(redirectURL);
    }
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:48,代码来源:ManageProgramServlet.java

示例12: toJson

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
/**
* Returns station as a JSON object.
* @return A station in JSON format
*/
  @Get("json")
  public StationSimple toJson() {
  	
  	String queryInfo = (String) getRequest().getAttributes()
              .get("queryinfo");

   char searchBy = queryInfo.charAt(0);
   String searchString = queryInfo.substring(2);
       
   Key stationKey = KeyFactory.stringToKey(searchString);
   log.info("Query: " + searchBy + "=" + searchString);

   // Get station
   Station station = StationManager.getStation(stationKey);
   
  	// First, get and create the channels
  	ArrayList<ChannelSimple> simpleChannels = new ArrayList<ChannelSimple>();
  	List<Channel> channels = ChannelManager.getStationChannels(station.getKey());
  	for (Channel channel : channels) {
  		Key channelKey = channel.getKey();	// TODO: Remove?
  		BlobKey firstSlideBlobKey =// new BlobKey("");
  				ChannelManager.getFirstSlideBlobKey(channel);
  		ChannelSimple channelSimple = new ChannelSimple(
  				KeyFactory.keyToString(channel.getKey()),
  				channel.getChannelName(),
  				channel.getChannelNumber(),
  				firstSlideBlobKey
  				);
  		simpleChannels.add(channelSimple);
  	}
   
  	// Then create the station simple
  	StationSimple stationSimple = new StationSimple(
  			KeyFactory.keyToString(station.getKey()),
  			station.getStationType(),
  			station.getStationPrivilegeLevel(),
  			station.getStationName(),
  			station.getStationNumber(),
  			station.getStationDescription(),
  			RegionManager.getRegion(station.getRegion()).getRegionName(),
  			station.getStationAddress() != null ? 
  					station.getStationAddress().getAddress() : "",
  			station.getStationWebsite() != null ? 
  					station.getStationWebsite().getValue() : "",
  			station.getUser().getUserEmail().getEmail(),
  			station.getStationLogo() != null ? 
  					station.getStationLogo() : new BlobKey(""),
  			station.getStationComments() != null ?
  					station.getStationComments() : "",
  			simpleChannels);

  	return stationSimple;
  }
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:58,代码来源:StationProfileResource.java

示例13: toJson

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
/**
* Returns the simple station list as a JSON object.
* @return An ArrayList of StationSimple in JSON format
*/
  @Get("json")
  public ArrayList<StationSimple> toJson() {
      
      List<Station> stations = StationManager.getAllStations();
      
      ArrayList<StationSimple> simpleStations = new ArrayList<StationSimple>();
      for (Station station : stations) {
      	
      	// First, get and create the channels
      	ArrayList<ChannelSimple> simpleChannels = new ArrayList<ChannelSimple>();
      	List<Channel> channels = ChannelManager.getStationChannels(station.getKey());
      	for (Channel channel : channels) {
      		Key channelKey = channel.getKey();
      		BlobKey firstSlideBlobKey = 
      				ChannelManager.getFirstSlideBlobKey(channelKey);
      		ChannelSimple channelSimple = new ChannelSimple(
      				KeyFactory.keyToString(channel.getKey()),
      				channel.getChannelName(),
      				channel.getChannelNumber(),
      				firstSlideBlobKey
      				);
      		simpleChannels.add(channelSimple);
      	}
      	
      	// Then create the stations
      	StationSimple stationSimple = new StationSimple(
      			KeyFactory.keyToString(station.getKey()),
      			station.getStationType(),
      			station.getStationPrivilegeLevel(),
      			station.getStationName(),
      			station.getStationNumber(),
      			station.getStationDescription(),
      			RegionManager.getRegion(station.getRegion()).getRegionName(),
      			station.getStationAddress() != null ? 
      					station.getStationAddress().getAddress() : "",
      			station.getStationWebsite() != null ? 
      					station.getStationWebsite().getValue() : "",
      			station.getUser().getUserEmail().getEmail(),
      			station.getStationLogo() != null ? 
      					station.getStationLogo() : new BlobKey(""),
      			station.getStationComments() != null ?
      					station.getStationComments() : "",
      			simpleChannels);
      	simpleStations.add(stationSimple);
      }
      
      return simpleStations;
  }
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:53,代码来源:StationsResource.java

示例14: toJson

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
/**
* Returns the playlist list as a JSON object.
* @return An ArrayList of playlist in JSON format
*/
  @Get("json")
  public ArrayList<PlaylistSimple> toJson() {
  	
  	String queryInfo = (String) getRequest().getAttributes()
              .get("queryinfo");

   char searchBy = queryInfo.charAt(0);
   String searchString = queryInfo.substring(2);
       
   Key stationKey = KeyFactory.stringToKey(searchString);
   log.info("Query: " + searchBy + "=" + searchString);

   // Get all the playlists from every station
   List<Playlist> playlistList = PlaylistManager.getStationPlaylists(stationKey);

      ArrayList<PlaylistSimple> playlistListSimple = new ArrayList<PlaylistSimple>();
      for (Playlist playlist : playlistList) {

      	// Create PlaylistMusicFiles
      	List<PlaylistMusicFile> playlistMusicFiles = 
      			PlaylistMusicFileManager.getAllPlaylistMusicFilesFromPlaylist(
      					playlist.getKey(), true);
      	ArrayList<PlaylistMusicFileSimple> playlistMusicFilesSimple = 
      			new ArrayList<PlaylistMusicFileSimple>();
      	for (PlaylistMusicFile playlistMusicFile : playlistMusicFiles) {
      		PlaylistMusicFileSimple playlistMusicFileSimple = 
      				new PlaylistMusicFileSimple(
      						playlistMusicFile.getMusicFileKey(),
      						playlistMusicFile.getPlaylistMusicFileSequenceNumber()
      						);
      		playlistMusicFilesSimple.add(playlistMusicFileSimple);
      	}
      	
      	PlaylistSimple playlistSimple = new PlaylistSimple(
      			KeyFactory.keyToString(playlist.getKey()),
      			playlist.getPlaylistName(),
      			playlistMusicFilesSimple,
      			DateManager.printDateAsString(
      					playlist.getPlaylistCreationDate()),
      			DateManager.printDateAsString(
      					playlist.getPlaylistModificationDate())
      			);
      	
      	playlistListSimple.add(playlistSimple);
      }
      
      return playlistListSimple;
  }
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:53,代码来源:PlaylistsResource.java

示例15: ReferentialIntegrityException

import com.google.appengine.api.datastore.KeyFactory; //导入方法依赖的package包/类
public ReferentialIntegrityException(Key key, String message) {
	super("Object key: " + KeyFactory.keyToString(key) + ". " + message);
}
 
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:4,代码来源:ReferentialIntegrityException.java


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