001/* 002 * Copyright 2017 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.odfsync.apogee.scc.impl; 017 018import java.util.List; 019import java.util.Map; 020 021import org.apache.commons.lang3.tuple.Pair; 022import org.slf4j.Logger; 023 024import org.ametys.cms.repository.ModifiableContent; 025import org.ametys.odf.program.ProgramPart; 026import org.ametys.odf.program.TraversableProgramPart; 027import org.ametys.plugins.odfsync.apogee.scc.AbstractApogeeSynchronizableContentsWithCatalogCollection; 028 029/** 030 * SCC for subprogram contents. 031 */ 032public class SubProgramSynchronizableContentsCollection extends AbstractApogeeSynchronizableContentsWithCatalogCollection 033{ 034 /** SCC model id */ 035 public static final String MODEL_ID = "org.ametys.plugins.odfsync.apogee.scc.subprogram"; 036 037 @Override 038 protected List<Map<String, Object>> _search(Map<String, Object> searchParams, Logger logger) 039 { 040 return _convertBigDecimal(_apogeeDAO.searchSubPrograms(getDataSourceId(), getParameterValues(), searchParams)); 041 } 042 043 @Override 044 protected String getMappingName() 045 { 046 return "subprogram"; 047 } 048 049 @Override 050 protected Pair<String, Object> getParentAttribute(ModifiableContent parent) 051 { 052 if (parent instanceof TraversableProgramPart) 053 { 054 return Pair.of(ProgramPart.PARENT_PROGRAM_PARTS, new ModifiableContent[] {parent}); 055 } 056 057 return super.getParentAttribute(parent); 058 } 059 060 @Override 061 protected String getChildrenAttributeName() 062 { 063 return TraversableProgramPart.CHILD_PROGRAM_PARTS; 064 } 065}