Package com.tll.server.marshal

Examples of com.tll.server.marshal.Marshaler


      // presume not logged in yet
      status.addMsg("Admin Context not found.", MsgLevel.INFO, MsgAttr.STATUS.flag);
      return new AdminContextPayload(status, ac.isDebug(), ac.getEnvironment(), null, null);
    }

    final Marshaler entityMarshaller = mec.getMarshaler();
    assert entityMarshaller != null : "No marshaler present";

    final Model user = entityMarshaller.marshalEntity(sac.getUser(), new MarshalOptions(true, 1, null));
    // NOTE: we want a distinct copy of the account here so we separately
    // marshall the account as opposed to grabbing the nested account from the
    // just marshaled user
    final Model account = entityMarshaller.marshalEntity(sac.getUser().getAccount(), MarshalOptions.NON_RELATIONAL);

    status.addMsg("Admin Context retrieved.", MsgLevel.INFO, MsgAttr.STATUS.flag);
    return new AdminContextPayload(status, ac.isDebug(), ac.getEnvironment(), user, account);
  }
View Full Code Here


      final AccountInterface ai = isvc.loadAccountInterface(ais.getAccountId(), ais.getInterfaceId());

      // set the quasi-id
      ai.setId(ais.getAccountId() + '|' + ais.getInterfaceId());

      final Marshaler marshaler = context.getMarshaler();
      final MarshalOptions moptions = context.getMarshalOptionsResolver().resolve(SmbizEntityType.ACCOUNT_INTERFACE);
      final Model m = marshaler.marshalEntity(ai, moptions);
      payload.setModel(m);
    }
    else
      throw new IllegalArgumentException("Unhandled account interface data search type.");
  }
View Full Code Here

    final RequestContext rc = getRequestContext();
    final PersistServiceDelegate delegate = (PersistServiceDelegate) rc.getServletContext().getAttribute(PersistServiceDelegate.KEY);
    final PersistContext mec = (PersistContext) rc.getServletContext().getAttribute(PersistContext.KEY);
    final com.tll.server.AdminContext sac =
      (com.tll.server.AdminContext) rc.getSession().getAttribute(com.tll.server.AdminContext.KEY);
    final Marshaler em = mec.getMarshaler();
    assert delegate != null && em != null && sac != null;

    final ModelPayload ep = delegate.load(new LoadRequest<PrimaryKeySearch>(new PrimaryKeySearch(accountRef)));
    final Status status = ep.getStatus();
View Full Code Here

  @Override
  public void doUpdate(Model model, ModelPayload payload) {
    // [re-]set the account interface options for a given interface and account

    final Marshaler marshaler = context.getMarshaler();

    final IInterfaceService isvc = context.getEntityServiceFactory().instance(IInterfaceService.class);

    final String id = model.getId();
    final String accountId = id.substring(0, id.indexOf('|'));
    final String intfId = id.substring(id.indexOf('|')+1);
    AccountInterface ai = isvc.loadAccountInterface(accountId, intfId);

    ai = marshaler.marshalModel(model, ai);
    isvc.setAccountInterface(ai);

    final MarshalOptions moptions = context.getMarshalOptionsResolver().resolve(SmbizEntityType.ACCOUNT_INTERFACE);
    final Model m = marshaler.marshalEntity(ai, moptions);
    payload.setModel(m);
  }
View Full Code Here

    final AppContext ac = (AppContext) getServletContext().getAttribute(AppContext.KEY);
    assert ac != null;
    final com.tll.service.entity.account.AddAccountService svc = ac.getAddAccountService();
    final PersistContext pc = (PersistContext) getServletContext().getAttribute(PersistContext.KEY);
    assert svc != null && pc != null;
    final Marshaler mlr = pc.getMarshaler();

    Class<? extends Account> accountClass;
    try {
      accountClass = (Class<? extends Account>) pc.getEntityTypeResolver().resolveEntityClass(request.getEntityType());
    }
    catch(final ClassCastException e) {
      s.addMsg("Invalid account type.", MsgLevel.ERROR, MsgAttr.STATUS.flag);
      return p;
    }
    Model maccount = request.getAccount();
    if(maccount == null) {
      s.addMsg("No account specified.", MsgLevel.ERROR, MsgAttr.STATUS.flag);
      return p;
    }
    final Collection<Model> maios = request.getAccountInterfaces();
    if(maios == null) {
      s.addMsg("No account interface options specified.", MsgLevel.ERROR, MsgAttr.STATUS.flag);
      return p;
    }
    final Collection<Model> musers = request.getUsers();

    try {
      // un-marshal
      Account account = mlr.marshalModel(maccount, accountClass);

      final ArrayList<AccountInterface> aios = new ArrayList<AccountInterface>(maios.size());
      for(final Model maio : maios) {
        aios.add(mlr.marshalModel(maio, AccountInterface.class));
      }

      final ArrayList<User> users = musers == null ? null : new ArrayList<User>(musers.size());
      if(musers != null) {
        for(final Model muser : musers) {
          users.add(mlr.marshalModel(muser, User.class));
        }
      }

      if(Isp.class == accountClass) {
        account = svc.addIsp((Isp) account, aios, users);
        s.addMsg("Isp added", MsgLevel.INFO, MsgAttr.STATUS.flag);
      }
      else if(Merchant.class == accountClass) {
        account = svc.addMerchant((Merchant) account, aios, users);
        s.addMsg("Merchant added", MsgLevel.INFO, MsgAttr.STATUS.flag);
      }
      else if(Customer.class == accountClass) {
        account = svc.addCustomer((Customer) account, aios, users);
        s.addMsg("Customer added", MsgLevel.INFO, MsgAttr.STATUS.flag);
      }
      else {
        s.addMsg("Unhandled account type: " + accountClass, MsgLevel.ERROR, MsgAttr.STATUS.flag);
        return p;
      }

      // marshal the added account
      maccount = mlr.marshalEntity(account, pc.getMarshalOptionsResolver().resolve(SmbizEntityType.ACCOUNT));
      p.setModel(maccount);

      return p;
    }
    catch(final RuntimeException e) {
View Full Code Here

TOP

Related Classes of com.tll.server.marshal.Marshaler

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.