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.portlet.dynamicdatamapping;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.json.JSONArray;
019    import com.liferay.portal.kernel.search.Document;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.service.ServiceContext;
022    
023    import java.io.Serializable;
024    
025    import java.util.List;
026    import java.util.Locale;
027    import java.util.Map;
028    
029    /**
030     * @author Leonardo Barros
031     */
032    public interface DDMStructureManager {
033    
034            public static final int STRUCTURE_COMPARATOR_STRUCTURE_KEY = 0;
035    
036            public static final long STRUCTURE_DEFAULT_PARENT_STRUCTURE_ID = 0;
037    
038            public static final String STRUCTURE_INDEXER_FIELD_NAMESPACE = "ddm";
039    
040            public static final String STRUCTURE_INDEXER_FIELD_PREFIX =
041                    DDMStructureManager.STRUCTURE_INDEXER_FIELD_NAMESPACE +
042                            DDMStructureManager.STRUCTURE_INDEXER_FIELD_SEPARATOR;
043    
044            public static final String STRUCTURE_INDEXER_FIELD_SEPARATOR =
045                    StringPool.DOUBLE_UNDERLINE;
046    
047            public static final int STRUCTURE_TYPE_AUTO = 1;
048    
049            public static final int STRUCTURE_TYPE_DEFAULT = 0;
050    
051            public static final String STRUCTURE_VERSION_DEFAULT = "1.0";
052    
053            public void addAttributes(
054                            long structureId, Document document, DDMFormValues ddmFormValues)
055                    throws PortalException;
056    
057            public DDMStructure addStructure(
058                            long userId, long groupId, String parentStructureKey,
059                            long classNameId, String structureKey, Map<Locale, String> nameMap,
060                            Map<Locale, String> descriptionMap, DDMForm ddmForm,
061                            String storageType, int type, ServiceContext serviceContext)
062                    throws PortalException;
063    
064            public void deleteStructure(long structureId) throws PortalException;
065    
066            public String extractAttributes(
067                            long structureId, DDMFormValues ddmFormValues, Locale locale)
068                    throws PortalException;
069    
070            public DDMStructure fetchStructure(long structureId);
071    
072            public DDMStructure fetchStructure(
073                    long groupId, long classNameId, String structureKey);
074    
075            public DDMStructure fetchStructureByUuidAndGroupId(
076                    String uuid, long groupId);
077    
078            public List<DDMStructure> getClassStructures(
079                    long companyId, long classNameId);
080    
081            public List<DDMStructure> getClassStructures(
082                    long companyId, long classNameId, int structureComparator);
083    
084            public List<DDMStructure> getClassStructures(
085                    long companyId, long classNameId, int start, int end);
086    
087            public JSONArray getDDMFormFieldsJSONArray(long structureId, String script)
088                    throws PortalException;
089    
090            public Class<?> getDDMStructureModelClass();
091    
092            public Serializable getIndexedFieldValue(
093                            Serializable fieldValue, String fieldType)
094                    throws Exception;
095    
096            public DDMStructure getStructure(long structureId) throws PortalException;
097    
098            public DDMStructure getStructure(
099                            long groupId, long classNameId, String structureKey)
100                    throws PortalException;
101    
102            public DDMStructure getStructureByUuidAndGroupId(String uuid, long groupId)
103                    throws PortalException;
104    
105            public List<DDMStructure> getStructures(long[] groupIds, long classNameId);
106    
107            public int getStructureStorageLinksCount(long structureId);
108    
109            public DDMStructure updateStructure(
110                            long userId, long structureId, long parentStructureId,
111                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
112                            DDMForm ddmForm, ServiceContext serviceContext)
113                    throws PortalException;
114    
115            public void updateStructureDefinition(
116                    long structureId, String definition) throws PortalException;
117    
118            public void updateStructureKey(long structureId, String structureKey)
119                    throws PortalException;
120    
121    }