All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.dirigible.components.odata.service.ODataHandlerService Maven / Gradle / Ivy

There is a newer version: 10.6.37
Show newest version
/*
 * Copyright (c) 2024 Eclipse Dirigible contributors
 *
 * All rights reserved. This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v20.html
 *
 * SPDX-FileCopyrightText: Eclipse Dirigible contributors SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.dirigible.components.odata.service;

import java.util.List;
import org.eclipse.dirigible.components.base.artefact.BaseArtefactService;
import org.eclipse.dirigible.components.odata.domain.ODataHandler;
import org.eclipse.dirigible.components.odata.repository.ODataHandlerRepository;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class ODataHandlerService.
 */
@Service
@Transactional
public class ODataHandlerService extends BaseArtefactService implements InitializingBean {

    /**
     * Instantiates a new o data handler service.
     *
     * @param repository the repository
     */
    public ODataHandlerService(ODataHandlerRepository repository) {
        super(repository);
    }

    /** The instance. */
    private static ODataHandlerService INSTANCE;

    /**
     * After properties set.
     *
     * @throws Exception the exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        INSTANCE = this;
    }

    /**
     * Gets the.
     *
     * @return the o data handler service
     */
    public static ODataHandlerService get() {
        return INSTANCE;
    }

    /**
     * Removes the handler.
     *
     * @param location the location
     */
    public void removeHandlers(String location) {
        ODataHandler filter = new ODataHandler();
        filter.setLocation(location);
        Example example = Example.of(filter);
        getRepo().deleteAll(getRepo().findAll(example));
    }

    /**
     * Gets the by namespace name method and kind.
     *
     * @param namespace the namespace
     * @param name the name
     * @param method the method
     * @param kind the kind
     * @return the by namespace name method and kind
     */
    public List getByNamespaceNameMethodAndKind(String namespace, String name, String method, String kind) {
        ODataHandler filter = new ODataHandler();
        filter.setNamespace(namespace);
        filter.setName(name);
        filter.setMethod(method);
        filter.setKind(kind);
        Example example = Example.of(filter);
        return getRepo().findAll(example);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy