(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( AssetCategory.class);
(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( AssetTag.class);
@Override public boolean validateReference( PortletDataContext portletDataContext, Element referenceElement) { validateMissingGroupReference(portletDataContext, referenceElement); String uuid = referenceElement.attributeValue("uuid"); Map<Long, Long> groupIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class); long groupId = GetterUtil.getLong( referenceElement.attributeValue("group-id")); groupId = MapUtil.getLong(groupIds, groupId); try { return validateMissingReference(uuid, groupId); } catch (Exception e) { return false; } }
protected void doImportMissingReference( PortletDataContext portletDataContext, Element referenceElement) throws PortletDataException { importMissingGroupReference(portletDataContext, referenceElement); String uuid = referenceElement.attributeValue("uuid"); Map<Long, Long> groupIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class); long groupId = GetterUtil.getLong( referenceElement.attributeValue("group-id")); groupId = MapUtil.getLong(groupIds, groupId); long classPK = GetterUtil.getLong( referenceElement.attributeValue("class-pk")); importMissingReference(portletDataContext, uuid, groupId, classPK); }
protected FileEntry fetchImportedFileEntry( PortletDataContext portletDataContext, long oldClassPK) throws PortalException { Map<Long, Long> fileEntryPKs = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( DLFileEntry.class); Long classPK = fileEntryPKs.get(oldClassPK); if (classPK == null) { return null; } return _dlAppService.getFileEntry(classPK); }
(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap(clazz);
@Override protected void doImportMissingReference( PortletDataContext portletDataContext, String uuid, long groupId, long recordId) throws Exception { DDMFormInstanceRecord existingRecord = fetchMissingReference( uuid, groupId); Map<Long, Long> recordIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( DDMFormInstanceRecord.class); recordIds.put(recordId, existingRecord.getFormInstanceRecordId()); }
@Override protected void doImportMissingReference( PortletDataContext portletDataContext, String uuid, long groupId, long formInstanceId) throws Exception { DDMFormInstance existingFormInstance = fetchMissingReference( uuid, groupId); Map<Long, Long> formInstanceIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( DDMFormInstance.class); formInstanceIds.put( formInstanceId, existingFormInstance.getFormInstanceId()); }
protected Layout fetchImportedLayout( PortletDataContext portletDataContext, JSONObject jsonObject) { Map<Long, Layout> layouts = (Map<Long, Layout>)portletDataContext.getNewPrimaryKeysMap( Layout.class + ".layout"); long layoutId = jsonObject.getLong("layoutId"); Layout layout = layouts.get(layoutId); if (layout == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to find layout with ID " + layoutId); } } return layout; }
(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( DDMStructure.class);
@Override public PortletDataContext createImportPortletDataContext( long companyId, long groupId, Map<String, String[]> parameterMap, UserIdStrategy userIdStrategy, ZipReader zipReader) throws PortletDataException { PortletDataContext portletDataContext = createPortletDataContext( companyId, groupId); String dataStrategy = MapUtil.getString( parameterMap, PortletDataHandlerKeys.DATA_STRATEGY, PortletDataHandlerKeys.DATA_STRATEGY_MIRROR); portletDataContext.setDataStrategy(dataStrategy); portletDataContext.setNewLayouts(new ArrayList<Layout>()); portletDataContext.setParameterMap(parameterMap); portletDataContext.setUserIdStrategy(userIdStrategy); portletDataContext.setZipReader(zipReader); readXML(portletDataContext); Map<Long, Long> groupIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class); groupIds.put( portletDataContext.getSourceCompanyGroupId(), portletDataContext.getCompanyGroupId()); return portletDataContext; }
protected void updateImportOrderByColumnClassPKs( PortletDataContext portletDataContext, PortletPreferences portletPreferences, String key, long companyGroupId) throws Exception { String oldValue = portletPreferences.getValue(key, null); Map<Long, Long> primaryKeys = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( DDMStructure.class); String[] ddmStructureFieldNameParts = StringUtil.split( oldValue, DDMIndexer.DDM_FIELD_SEPARATOR); String portletPreferencesOldValue = ddmStructureFieldNameParts[2]; Long newPrimaryKey = getImportPortletPreferencesNewValue( portletDataContext, DDMStructure.class, companyGroupId, primaryKeys, portletPreferencesOldValue); if (Validator.isNull(newPrimaryKey)) { if (_log.isInfoEnabled()) { _log.info( "Unable to import portlet preferences value " + portletPreferencesOldValue); } return; } String newValue = StringUtil.replace( oldValue, portletPreferencesOldValue, newPrimaryKey.toString()); portletPreferences.setValue(key, newValue); }
protected void deletePortletData(PortletDataContext portletDataContext) throws Exception { List<Element> portletElements = fetchPortletElements( portletDataContext.getImportDataRootElement()); Map<Long, Layout> layouts = (Map<Long, Layout>)portletDataContext.getNewPrimaryKeysMap( Layout.class + ".layout"); if (_log.isDebugEnabled()) { if (!portletElements.isEmpty()) { _log.debug("Deleting portlet data"); } } for (Element portletElement : portletElements) { long layoutId = GetterUtil.getLong( portletElement.attributeValue("layout-id")); long plid = LayoutConstants.DEFAULT_PLID; Layout layout = layouts.get(layoutId); if (layout != null) { plid = layout.getPlid(); } portletDataContext.setPlid(plid); portletDataContext.setPortletId( portletElement.attributeValue("portlet-id")); _portletImportController.deletePortletData(portletDataContext); } }
protected FileEntry fetchImportedFileEntry( PortletDataContext portletDataContext, JSONObject jsonObject) throws PortalException { Map<Long, Long> groupIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class); long groupId = jsonObject.getLong("groupId"); String uuid = jsonObject.getString("uuid"); groupId = MapUtil.getLong(groupIds, groupId, groupId); if ((groupId > 0) && Validator.isNotNull(uuid)) { try { return _dlAppService.getFileEntryByUuidAndGroupId( uuid, groupId); } catch (NoSuchFileEntryException nsfee) { if (_log.isWarnEnabled()) { _log.warn( StringBundler.concat( "Unable to find file entry with uuid ", uuid, " and groupId ", groupId), nsfee); } } } return null; }
protected MissingReference validateMissingReference( PortletDataContext portletDataContext, Element element) { // Missing reference is exported after added as missing if (Validator.isNotNull(element.attributeValue("element-path"))) { return null; } String className = element.attributeValue("class-name"); StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler( className); if (!stagedModelDataHandler.validateReference( portletDataContext, element)) { MissingReference missingReference = new MissingReference(element); Map<Long, Long> groupIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class); long groupId = MapUtil.getLong( groupIds, GetterUtil.getLong(element.attributeValue("group-id"))); missingReference.setGroupId(groupId); return missingReference; } return null; }
(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( JournalArticle.class + ".primaryKey");
private void _importAssetDisplayPage( PortletDataContext portletDataContext, JournalArticle article, JournalArticle importedArticle) { List<Element> assetDisplayPageEntryElements = portletDataContext.getReferenceDataElements( article, AssetDisplayPageEntry.class); for (Element assetDisplayPageEntryElement : assetDisplayPageEntryElements) { String path = assetDisplayPageEntryElement.attributeValue("path"); AssetDisplayPageEntry assetDisplayPageEntry = (AssetDisplayPageEntry)portletDataContext.getZipEntryAsObject( path); Map<Long, Long> assetDisplayPageEntries = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( AssetDisplayPageEntry.class); long assetDisplayPageEntryId = MapUtil.getLong( assetDisplayPageEntries, assetDisplayPageEntry.getAssetDisplayPageEntryId(), assetDisplayPageEntry.getAssetDisplayPageEntryId()); AssetDisplayPageEntry existingAssetDisplayPageEntry = _assetDisplayPageEntryLocalService.fetchAssetDisplayPageEntry( assetDisplayPageEntryId); if (existingAssetDisplayPageEntry != null) { existingAssetDisplayPageEntry.setClassPK( importedArticle.getResourcePrimKey()); _assetDisplayPageEntryLocalService.updateAssetDisplayPageEntry( existingAssetDisplayPageEntry); } } }
@Override public boolean validateReference( PortletDataContext portletDataContext, Element referenceElement) { validateMissingGroupReference(portletDataContext, referenceElement); String uuid = referenceElement.attributeValue("uuid"); String articleResourceUuid = referenceElement.attributeValue( "article-resource-uuid"); Map<Long, Long> groupIds = (Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class); long groupId = GetterUtil.getLong( referenceElement.attributeValue("group-id")); groupId = MapUtil.getLong(groupIds, groupId); String articleArticleId = referenceElement.attributeValue("article-id"); boolean preloaded = GetterUtil.getBoolean( referenceElement.attributeValue("preloaded")); if (!preloaded) { return super.validateMissingReference(uuid, groupId); } JournalArticle existingArticle = fetchExistingArticleWithParentGroups( uuid, articleResourceUuid, groupId, articleArticleId, null, 0.0, preloaded); if (existingArticle == null) { return false; } return true; }
(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( Group.class);
(Map<Long, Long>)portletDataContext.getNewPrimaryKeysMap( DDMStructure.class);