@Override public void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException { Group group = GroupLocalServiceUtil.getGroup(groupId); Address address = AddressLocalServiceUtil.fetchAddressByUuidAndCompanyId(uuid, group.getCompanyId()); if (address != null) { AddressLocalServiceUtil.deleteAddress(address); } }
@Override protected void doImportStagedModel(PortletDataContext portletDataContext, Address address) throws Exception { long userId = portletDataContext.getUserId(address.getUserUuid()); ServiceContext serviceContext = portletDataContext.createServiceContext(address); Address existingAddress = AddressLocalServiceUtil.fetchAddressByUuidAndCompanyId( address.getUuid(), portletDataContext.getCompanyId()); Address importedAddress = null; if (existingAddress == null) { serviceContext.setUuid(address.getUuid()); importedAddress = AddressLocalServiceUtil.addAddress( userId, address.getClassName(), address.getClassPK(), address.getStreet1(), address.getStreet2(), address.getStreet3(), address.getCity(), address.getZip(), address.getRegionId(), address.getCountryId(), address.getTypeId(), address.getMailing(), address.isPrimary(), serviceContext); } else { importedAddress = AddressLocalServiceUtil.updateAddress( existingAddress.getAddressId(), address.getStreet1(), address.getStreet2(), address.getStreet3(), address.getCity(), address.getZip(), address.getRegionId(), address.getCountryId(), address.getTypeId(), address.getMailing(), address.isPrimary()); } portletDataContext.importClassedModel(address, importedAddress); }