@Test public void testDynamicQueryByProjectionExisting() throws Exception { ExportImportConfiguration newExportImportConfiguration = addExportImportConfiguration(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( ExportImportConfiguration.class, ExportImportConfiguration.class.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.property("exportImportConfigurationId")); Object newExportImportConfigurationId = newExportImportConfiguration.getExportImportConfigurationId(); dynamicQuery.add( RestrictionsFactoryUtil.in( "exportImportConfigurationId", new Object[] {newExportImportConfigurationId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingExportImportConfigurationId = result.get(0); Assert.assertEquals(existingExportImportConfigurationId, newExportImportConfigurationId); }
@Override protected void doDelete(Object obj) throws Exception { ExportImportConfiguration exportImportConfiguration = (ExportImportConfiguration) obj; deleteDocument( exportImportConfiguration.getCompanyId(), exportImportConfiguration.getExportImportConfigurationId()); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { ExportImportConfiguration newExportImportConfiguration = addExportImportConfiguration(); ExportImportConfiguration existingExportImportConfiguration = _persistence.fetchByPrimaryKey(newExportImportConfiguration.getPrimaryKey()); Assert.assertEquals(existingExportImportConfiguration, newExportImportConfiguration); }
@Override protected void doReindex(Object obj) throws Exception { ExportImportConfiguration exportImportConfiguration = (ExportImportConfiguration) obj; Document document = getDocument(exportImportConfiguration); SearchEngineUtil.updateDocument( getSearchEngineId(), exportImportConfiguration.getCompanyId(), document); }
@Test public void testCreate() throws Exception { long pk = ServiceTestUtil.nextLong(); ExportImportConfiguration exportImportConfiguration = _persistence.create(pk); Assert.assertNotNull(exportImportConfiguration); Assert.assertEquals(exportImportConfiguration.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { ExportImportConfiguration newExportImportConfiguration = addExportImportConfiguration(); _persistence.remove(newExportImportConfiguration); ExportImportConfiguration existingExportImportConfiguration = _persistence.fetchByPrimaryKey(newExportImportConfiguration.getPrimaryKey()); Assert.assertNull(existingExportImportConfiguration); }
@Override public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException { ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask); Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); long userId = MapUtil.getLong(settingsMap, "userId"); long groupId = MapUtil.getLong(settingsMap, "sourceGroupId"); boolean privateLayout = MapUtil.getBoolean(settingsMap, "privateLayout"); long[] layoutIds = GetterUtil.getLongValues(settingsMap.get("layoutIds")); Map<String, String[]> parameterMap = (Map<String, String[]>) settingsMap.get("parameterMap"); DateRange dateRange = ExportImportDateUtil.getDateRange( exportImportConfiguration, ExportImportDateUtil.RANGE_ALL); StringBundler sb = new StringBundler(4); sb.append( StringUtil.replace( exportImportConfiguration.getName(), StringPool.SPACE, StringPool.UNDERLINE)); sb.append(StringPool.DASH); sb.append(Time.getShortTimestamp()); sb.append(".lar"); File larFile = LayoutLocalServiceUtil.exportLayoutsAsFile( groupId, privateLayout, layoutIds, parameterMap, dateRange.getStartDate(), dateRange.getEndDate()); BackgroundTaskLocalServiceUtil.addBackgroundTaskAttachment( userId, backgroundTask.getBackgroundTaskId(), sb.toString(), larFile); boolean updateLastPublishDate = MapUtil.getBoolean(parameterMap, PortletDataHandlerKeys.UPDATE_LAST_PUBLISH_DATE); if (updateLastPublishDate) { ExportImportDateUtil.updateLastPublishDate( groupId, privateLayout, dateRange, dateRange.getEndDate()); } return BackgroundTaskResult.SUCCESS; }
/** * Adds the export import configuration to the database. Also notifies the appropriate model * listeners. * * @param exportImportConfiguration the export import configuration * @return the export import configuration that was added */ @Indexable(type = IndexableType.REINDEX) @Override public ExportImportConfiguration addExportImportConfiguration( ExportImportConfiguration exportImportConfiguration) { exportImportConfiguration.setNew(true); return exportImportConfigurationPersistence.update(exportImportConfiguration); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { ExportImportConfiguration newExportImportConfiguration = addExportImportConfiguration(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( ExportImportConfiguration.class, ExportImportConfiguration.class.getClassLoader()); dynamicQuery.add( RestrictionsFactoryUtil.eq( "exportImportConfigurationId", newExportImportConfiguration.getExportImportConfigurationId())); List<ExportImportConfiguration> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); ExportImportConfiguration existingExportImportConfiguration = result.get(0); Assert.assertEquals(existingExportImportConfiguration, newExportImportConfiguration); }
@Override protected Document doGetDocument(Object obj) throws Exception { ExportImportConfiguration exportImportConfiguration = (ExportImportConfiguration) obj; Document document = getBaseModelDocument(PORTLET_ID, exportImportConfiguration); document.addText(Field.DESCRIPTION, exportImportConfiguration.getDescription()); document.addText(Field.NAME, exportImportConfiguration.getName()); document.addKeyword(Field.TYPE, exportImportConfiguration.getType()); Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap(); populateDates(document, settingsMap); populateLayoutIds(document, settingsMap); populateLocale(document, settingsMap); populateParameterMap(document, settingsMap); populateSiteInformation(document, settingsMap); populateTimeZone(document, settingsMap); document.addKeyword(_PREFIX_SETTING + Field.USER_ID, MapUtil.getLong(settingsMap, "userId")); return document; }
protected ExportImportConfiguration addExportImportConfiguration() throws Exception { long pk = ServiceTestUtil.nextLong(); ExportImportConfiguration exportImportConfiguration = _persistence.create(pk); exportImportConfiguration.setMvccVersion(ServiceTestUtil.nextLong()); exportImportConfiguration.setGroupId(ServiceTestUtil.nextLong()); exportImportConfiguration.setCompanyId(ServiceTestUtil.nextLong()); exportImportConfiguration.setUserId(ServiceTestUtil.nextLong()); exportImportConfiguration.setUserName(ServiceTestUtil.randomString()); exportImportConfiguration.setCreateDate(ServiceTestUtil.nextDate()); exportImportConfiguration.setModifiedDate(ServiceTestUtil.nextDate()); exportImportConfiguration.setName(ServiceTestUtil.randomString()); exportImportConfiguration.setDescription(ServiceTestUtil.randomString()); exportImportConfiguration.setType(ServiceTestUtil.nextInt()); exportImportConfiguration.setSettings(ServiceTestUtil.randomString()); exportImportConfiguration.setStatus(ServiceTestUtil.nextInt()); exportImportConfiguration.setStatusByUserId(ServiceTestUtil.nextLong()); exportImportConfiguration.setStatusByUserName(ServiceTestUtil.randomString()); exportImportConfiguration.setStatusDate(ServiceTestUtil.nextDate()); _persistence.update(exportImportConfiguration); return exportImportConfiguration; }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); ExportImportConfiguration newExportImportConfiguration = _persistence.create(pk); newExportImportConfiguration.setMvccVersion(ServiceTestUtil.nextLong()); newExportImportConfiguration.setGroupId(ServiceTestUtil.nextLong()); newExportImportConfiguration.setCompanyId(ServiceTestUtil.nextLong()); newExportImportConfiguration.setUserId(ServiceTestUtil.nextLong()); newExportImportConfiguration.setUserName(ServiceTestUtil.randomString()); newExportImportConfiguration.setCreateDate(ServiceTestUtil.nextDate()); newExportImportConfiguration.setModifiedDate(ServiceTestUtil.nextDate()); newExportImportConfiguration.setName(ServiceTestUtil.randomString()); newExportImportConfiguration.setDescription(ServiceTestUtil.randomString()); newExportImportConfiguration.setType(ServiceTestUtil.nextInt()); newExportImportConfiguration.setSettings(ServiceTestUtil.randomString()); newExportImportConfiguration.setStatus(ServiceTestUtil.nextInt()); newExportImportConfiguration.setStatusByUserId(ServiceTestUtil.nextLong()); newExportImportConfiguration.setStatusByUserName(ServiceTestUtil.randomString()); newExportImportConfiguration.setStatusDate(ServiceTestUtil.nextDate()); _persistence.update(newExportImportConfiguration); ExportImportConfiguration existingExportImportConfiguration = _persistence.findByPrimaryKey(newExportImportConfiguration.getPrimaryKey()); Assert.assertEquals( existingExportImportConfiguration.getMvccVersion(), newExportImportConfiguration.getMvccVersion()); Assert.assertEquals( existingExportImportConfiguration.getExportImportConfigurationId(), newExportImportConfiguration.getExportImportConfigurationId()); Assert.assertEquals( existingExportImportConfiguration.getGroupId(), newExportImportConfiguration.getGroupId()); Assert.assertEquals( existingExportImportConfiguration.getCompanyId(), newExportImportConfiguration.getCompanyId()); Assert.assertEquals( existingExportImportConfiguration.getUserId(), newExportImportConfiguration.getUserId()); Assert.assertEquals( existingExportImportConfiguration.getUserName(), newExportImportConfiguration.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingExportImportConfiguration.getCreateDate()), Time.getShortTimestamp(newExportImportConfiguration.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingExportImportConfiguration.getModifiedDate()), Time.getShortTimestamp(newExportImportConfiguration.getModifiedDate())); Assert.assertEquals( existingExportImportConfiguration.getName(), newExportImportConfiguration.getName()); Assert.assertEquals( existingExportImportConfiguration.getDescription(), newExportImportConfiguration.getDescription()); Assert.assertEquals( existingExportImportConfiguration.getType(), newExportImportConfiguration.getType()); Assert.assertEquals( existingExportImportConfiguration.getSettings(), newExportImportConfiguration.getSettings()); Assert.assertEquals( existingExportImportConfiguration.getStatus(), newExportImportConfiguration.getStatus()); Assert.assertEquals( existingExportImportConfiguration.getStatusByUserId(), newExportImportConfiguration.getStatusByUserId()); Assert.assertEquals( existingExportImportConfiguration.getStatusByUserName(), newExportImportConfiguration.getStatusByUserName()); Assert.assertEquals( Time.getShortTimestamp(existingExportImportConfiguration.getStatusDate()), Time.getShortTimestamp(newExportImportConfiguration.getStatusDate())); }