Development Examples
How to create an Article Structure Map entry on an Article Type based entity.
private void mapArticleToStructureGroup( ArticleProxy article, String structureGroupIdentifier, RevisionToken revisionToken, AccumulatedFeedbackProcessor feedbackProcessor ) throws CoreException { RepositoryService repositoryService = RepositoryComponent.getRepositoryService(); EntityType articleEntityType = article.getEntityType(); EntityType articleStructureMapEntityType = repositoryService.getEntityTypeByIdentifier( "ArticleStructureMapType" ); //$NON-NLS-1$ Entity articleEntity = article.getEntity(); Entity articleStructureMapEntity = repositoryService.getEntityByIdentifier( "ArticleStructureMap" ); //$NON-NLS-1$ LoadHint articleWithASMLoadHint = new LoadHintBuilder( articleEntityType ).add( articleStructureMapEntityType, false ) .build(); EntityDetailModel articleDetailModel = article.getDetailModel( articleWithASMLoadHint, true, revisionToken ); articleDetailModel.acquireWrite( null ); try { EDataObject articleDataObject = articleDetailModel.getDataObject(); EntityPath articleStructureMapEntityPath = new EntityPath( articleStructureMapEntityType ); articleStructureMapEntityPath.setLogicalKeyValue( "ArticleStructureMapType.LK.StructureId", structureGroup.getContainer().getId() ); //$NON-NLS-1$ FieldPath manualMapFieldPath = new FieldPath( articleStructureMapEntityPath, "ArticleStructureMapType.ManualMap" ); //$NON-NLS-1$ List< String > manualMapValue = new ArrayList<>(); manualMapValue.add( structureGroupIdentifier ); CommandContextParam commandContextParam = new CommandContextParam( articleEntity, articleDetailModel ); commandContextParam.setFeedbackProcessor( feedbackProcessor ); CommandContext commandContext = CommandContextFactory.createContext( commandContextParam ); PutCommand putCommand = ( PutCommand ) commandContext.getCommand( PutCommand.TYPE ); putCommand.put( commandContext, articleDataObject, articleDataObject, articleStructureMapEntity, manualMapFieldPath, manualMapValue, true ); if ( commandContext.isCanceled() ) { // do error handling, e.g. get the errors through feedbackProcessor.getFeedbacks() } else { articleDetailModel.save( null ); } } catch ( CoreException ce ) { // do error handling, e.g. log or rethrow exception } finally { articleDetailModel.releaseWrite(); } }