001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.dynamic.data.mapping.kernel;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.json.JSONArray;
021    import com.liferay.portal.kernel.search.Document;
022    import com.liferay.portal.kernel.service.ServiceContext;
023    import com.liferay.portal.kernel.util.StringPool;
024    
025    import java.io.Serializable;
026    
027    import java.util.List;
028    import java.util.Locale;
029    import java.util.Map;
030    
031    /**
032     * @author Leonardo Barros
033     */
034    @ProviderType
035    public interface DDMStructureManager {
036    
037            public static final int STRUCTURE_COMPARATOR_STRUCTURE_KEY = 0;
038    
039            public static final long STRUCTURE_DEFAULT_PARENT_STRUCTURE_ID = 0;
040    
041            public static final String STRUCTURE_INDEXER_FIELD_NAMESPACE = "ddm";
042    
043            public static final String STRUCTURE_INDEXER_FIELD_PREFIX =
044                    DDMStructureManager.STRUCTURE_INDEXER_FIELD_NAMESPACE +
045                            DDMStructureManager.STRUCTURE_INDEXER_FIELD_SEPARATOR;
046    
047            public static final String STRUCTURE_INDEXER_FIELD_SEPARATOR =
048                    StringPool.DOUBLE_UNDERLINE;
049    
050            public static final int STRUCTURE_TYPE_AUTO = 1;
051    
052            public static final int STRUCTURE_TYPE_DEFAULT = 0;
053    
054            public static final String STRUCTURE_VERSION_DEFAULT = "1.0";
055    
056            public void addAttributes(
057                            long structureId, Document document, DDMFormValues ddmFormValues)
058                    throws PortalException;
059    
060            public DDMStructure addStructure(
061                            long userId, long groupId, String parentStructureKey,
062                            long classNameId, String structureKey, Map<Locale, String> nameMap,
063                            Map<Locale, String> descriptionMap, DDMForm ddmForm,
064                            String storageType, int type, ServiceContext serviceContext)
065                    throws PortalException;
066    
067            public void deleteStructure(long structureId) throws PortalException;
068    
069            public String extractAttributes(
070                            long structureId, DDMFormValues ddmFormValues, Locale locale)
071                    throws PortalException;
072    
073            public DDMStructure fetchStructure(long structureId);
074    
075            public DDMStructure fetchStructure(
076                    long groupId, long classNameId, String structureKey);
077    
078            public DDMStructure fetchStructureByUuidAndGroupId(
079                    String uuid, long groupId);
080    
081            public List<DDMStructure> getClassStructures(
082                    long companyId, long classNameId);
083    
084            public List<DDMStructure> getClassStructures(
085                    long companyId, long classNameId, int structureComparator);
086    
087            public List<DDMStructure> getClassStructures(
088                    long companyId, long classNameId, int start, int end);
089    
090            public JSONArray getDDMFormFieldsJSONArray(long structureId, String script)
091                    throws PortalException;
092    
093            public Class<?> getDDMStructureModelClass();
094    
095            public Serializable getIndexedFieldValue(
096                            Serializable fieldValue, String fieldType)
097                    throws Exception;
098    
099            public DDMStructure getStructure(long structureId) throws PortalException;
100    
101            public DDMStructure getStructure(
102                            long groupId, long classNameId, String structureKey)
103                    throws PortalException;
104    
105            public DDMStructure getStructureByUuidAndGroupId(String uuid, long groupId)
106                    throws PortalException;
107    
108            public List<DDMStructure> getStructures(long[] groupIds, long classNameId);
109    
110            public int getStructureStorageLinksCount(long structureId);
111    
112            public DDMStructure updateStructure(
113                            long userId, long structureId, long parentStructureId,
114                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
115                            DDMForm ddmForm, ServiceContext serviceContext)
116                    throws PortalException;
117    
118            public void updateStructureDefinition(
119                    long structureId, String definition) throws PortalException;
120    
121            public void updateStructureKey(long structureId, String structureKey)
122                    throws PortalException;
123    
124    }