Package net.cloudcodex.shared.dto.msg

Examples of net.cloudcodex.shared.dto.msg.SceneDTO


   
    final Scene scene = sdo.getScene();
    final List<Message> messages = sdo.getMessages();
    final List<Data.Character> characters = sdo.getCharacters();
   
    final SceneDTO dto = new SceneDTO();
    dto.setId(scene.getKey().getId());
    dto.setCharacters(mapCharacterHeader(characters, scene, viewCharacterKey));
    dto.setMessages(mapMessage(messages));
   
    // use introduction as message
    final String introduction = scene.getIntroduction();
    if(introduction != null) {
      if(dto.getMessages() == null) {
        dto.setMessages(new ArrayList<MessageDTO>());
      }
      final MessageDTO messageDTO = new MessageDTO();
      messageDTO.setId(null);
      messageDTO.setAction(null);
      messageDTO.setAuthor(null);
      messageDTO.setContent(introduction);
      messageDTO.setIndex(0);
      messageDTO.setType(null);
      dto.getMessages().add(0, messageDTO);
    }
    dto.setTimestamp(scene.getTimestamp());
   
    if(viewCharacterKey != null) {
      // for a character, only its own informations
      final String viewCharacterKeyString = viewCharacterKey.toString();
      final Key next = scene.getNext(viewCharacterKeyString);
      if (next != null) {
        dto.getNext().put(viewCharacterKey, next.getId());
      }
      final Key previous = scene.getPrevious(viewCharacterKeyString);
      if (previous != null) {
        dto.getPrevious().put(viewCharacterKey, previous.getId());
      }
    } else {
      // for GM : all informations
      for(Map.Entry<String, Key> entry : scene.getNext().entrySet()) {
        try {
          final Long id = Long.valueOf(entry.getKey());
          dto.getNext().put(id, entry.getValue().getId());
        } catch (NumberFormatException e) {
          // ...
        }
      }
      for(Map.Entry<String, Key> entry : scene.getPrevious().entrySet()) {
        try {
          final Long id = Long.valueOf(entry.getKey());
          dto.getPrevious().put(id, entry.getValue().getId());
        } catch (NumberFormatException e) {
          // ...
        }
      }
    }
View Full Code Here


      return null;
    }
   
    final List<SceneDTO> dtos = new ArrayList<SceneDTO>();
    for(SceneSDO scene : scenes) {
      final SceneDTO dto = mapScene(scene, viewCharacterKey);
      if(dto != null) {
        dtos.add(dto);
      }
    }
   
View Full Code Here

TOP

Related Classes of net.cloudcodex.shared.dto.msg.SceneDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.