@Override
  protected void doImportStagedModel(
      PortletDataContext portletDataContext, WSRPConsumerPortlet wsrpConsumerPortlet)
      throws Exception {

    StagedModelDataHandlerUtil.importReferenceStagedModel(
        portletDataContext,
        wsrpConsumerPortlet,
        WSRPConsumer.class,
        wsrpConsumerPortlet.getWsrpConsumerId());

    Map<Long, Long> wsrpConsumerIds =
        (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(WSRPConsumer.class);

    long wsrpConsumerId =
        MapUtil.getLong(
            wsrpConsumerIds,
            wsrpConsumerPortlet.getWsrpConsumerId(),
            wsrpConsumerPortlet.getWsrpConsumerId());

    ServiceContext serviceContext = portletDataContext.createServiceContext(wsrpConsumerPortlet);

    WSRPConsumerPortlet importedWSRPConsumerPortlet = null;

    if (portletDataContext.isDataStrategyMirror()) {
      WSRPConsumerPortlet existingWSRPConsumerPortlet =
          WSRPConsumerPortletLocalServiceUtil.fetchWSRPConsumerPortletByUuidAndCompanyId(
              wsrpConsumerPortlet.getUuid(), portletDataContext.getCompanyId());

      if (existingWSRPConsumerPortlet == null) {
        serviceContext.setUuid(wsrpConsumerPortlet.getUuid());

        importedWSRPConsumerPortlet =
            WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet(
                wsrpConsumerId,
                wsrpConsumerPortlet.getName(),
                wsrpConsumerPortlet.getPortletHandle(),
                serviceContext);
      } else {
        existingWSRPConsumerPortlet.setWsrpConsumerId(wsrpConsumerId);
        existingWSRPConsumerPortlet.setName(wsrpConsumerPortlet.getName());
        existingWSRPConsumerPortlet.setPortletHandle(wsrpConsumerPortlet.getPortletHandle());

        importedWSRPConsumerPortlet =
            WSRPConsumerPortletLocalServiceUtil.updateWSRPConsumerPortlet(
                existingWSRPConsumerPortlet);
      }
    } else {
      importedWSRPConsumerPortlet =
          WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet(
              wsrpConsumerId,
              wsrpConsumerPortlet.getName(),
              wsrpConsumerPortlet.getPortletHandle(),
              serviceContext);
    }

    portletDataContext.importClassedModel(wsrpConsumerPortlet, importedWSRPConsumerPortlet);
  }
 public void persist() throws SystemException {
   if (this.isNew()) {
     WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet(this);
   } else {
     WSRPConsumerPortletLocalServiceUtil.updateWSRPConsumerPortlet(this);
   }
 }
  protected void importWSRPConsumerPortlet(
      PortletDataContext portletDataContext,
      WSRPConsumer wsrpConsumer,
      Element wsrpConsumerPortletElement,
      WSRPConsumerPortlet wsrpConsumerPortlet)
      throws Exception {

    try {
      WSRPConsumerPortlet importedWSRPConsumerPortlet =
          WSRPConsumerPortletLocalServiceUtil.getWSRPConsumerPortlet(wsrpConsumerPortlet.getUuid());

      importedWSRPConsumerPortlet.setWsrpConsumerId(wsrpConsumer.getWsrpConsumerId());
      importedWSRPConsumerPortlet.setName(wsrpConsumerPortlet.getName());
      importedWSRPConsumerPortlet.setPortletHandle(wsrpConsumerPortlet.getPortletHandle());

      WSRPConsumerPortletLocalServiceUtil.updateWSRPConsumerPortlet(
          importedWSRPConsumerPortlet, false);
    } catch (NoSuchConsumerPortletException nscpe) {
      ServiceContext serviceContext =
          portletDataContext.createServiceContext(
              wsrpConsumerPortletElement, wsrpConsumerPortlet, _NAMESPACE);

      serviceContext.setUuid(wsrpConsumerPortlet.getUuid());

      WSRPConsumerPortletLocalServiceUtil.addWSRPConsumerPortlet(
          wsrpConsumer.getUuid(),
          wsrpConsumerPortlet.getName(),
          wsrpConsumerPortlet.getPortletHandle(),
          null,
          serviceContext);
    }
  }