Esempio n. 1
0
  private String newScope(GameModel gameModel, VariableDescriptor vd) {
    StringBuilder sb = new StringBuilder();
    try {
      descriptorFacade.detach(vd);
      String name = vd.getName();
      String parentName = vd.getParentList().getName();

      GameModelScope scope = new GameModelScope();
      scope.setBroadcastScope("GameScope");
      vd.setScope(scope);
      String json = vd.toJson(Views.Export.class);
      logger.error("JSON for " + parentName + "/" + name + " variable: " + json);

      descriptorFacade.remove(vd.getId());
      descriptorFacade.flush();

      logger.error("REMOVED");

      sb.append("NAME: ")
          .append(name)
          .append(" -> ")
          .append(this.addVariable(gameModel, json, name, parentName));

    } catch (IOException ex) {
      java.util.logging.Logger.getLogger(UpdateController.class.getName())
          .log(Level.SEVERE, null, ex);
    }
    return sb.toString();
  }
Esempio n. 2
0
  private void updateScope(VariableDescriptor vd) {
    if (!(vd.getScope() instanceof GameModelScope)) {
      EntityManager em = this.getEntityManager();

      Collection<VariableInstance> values = vd.getScope().getVariableInstancesByKeyId().values();
      for (VariableInstance vi : values) {
        em.remove(vi);
      }
      GameModelScope scope = new GameModelScope();
      scope.setBroadcastScope("GameScope");
      scope.setVariableDescscriptor(vd);
      vd.setScope(scope);
      em.persist(vd);
      vd.propagateDefaultInstance(null, true);
    }
  }