@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); }
@Override protected void doExportStagedModel( PortletDataContext portletDataContext, WSRPConsumerPortlet wsrpConsumerPortlet) throws Exception { WSRPConsumer wsrpConsumer = WSRPConsumerLocalServiceUtil.getWSRPConsumer(wsrpConsumerPortlet.getWsrpConsumerId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, wsrpConsumerPortlet, wsrpConsumer, PortletDataContext.REFERENCE_TYPE_STRONG); Element wsrpConsumerPortletElement = portletDataContext.getExportDataElement(wsrpConsumerPortlet); portletDataContext.addClassedModel( wsrpConsumerPortletElement, ExportImportPathUtil.getModelPath(wsrpConsumerPortlet), wsrpConsumerPortlet); }