com.liferay.object.internal.info.collection.provider.RelatedInfoCollectionProviderFactory Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.object.internal.info.collection.provider;
import com.liferay.info.collection.provider.RelatedInfoItemCollectionProvider;
import com.liferay.object.constants.ObjectRelationshipConstants;
import com.liferay.object.model.ObjectDefinition;
import com.liferay.object.model.ObjectRelationship;
import com.liferay.object.service.ObjectEntryLocalService;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.language.Language;
import java.util.Objects;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Feliphe Marinho
*/
@Component(service = RelatedInfoCollectionProviderFactory.class)
public class RelatedInfoCollectionProviderFactory {
public RelatedInfoItemCollectionProvider create(
ObjectDefinition objectDefinition1,
ObjectDefinition objectDefinition2,
ObjectRelationship objectRelationship)
throws PortalException {
if (objectDefinition1.isSystem() || objectDefinition2.isSystem()) {
return null;
}
if (Objects.equals(
objectRelationship.getType(),
ObjectRelationshipConstants.TYPE_MANY_TO_MANY)) {
return new ManyToManyObjectRelationshipRelatedInfoCollectionProvider(
_language, objectDefinition1, objectDefinition2,
_objectEntryLocalService, objectRelationship);
}
else if (Objects.equals(
objectRelationship.getType(),
ObjectRelationshipConstants.TYPE_ONE_TO_MANY)) {
return new OneToManyObjectRelationshipRelatedInfoCollectionProvider(
_language, objectDefinition1, objectDefinition2,
_objectEntryLocalService, objectRelationship);
}
return null;
}
@Reference
private Language _language;
@Reference
private ObjectEntryLocalService _objectEntryLocalService;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy