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

com.sap.cloud.spring.boot.mt.cds.EdmxModelCreator Maven / Gradle / Ivy

/******************************************************************************
 * © 2020 SAP SE or an SAP affiliate company. All rights reserved.            *
 ******************************************************************************/

package com.sap.cloud.spring.boot.mt.cds;

import com.sap.cds.mtx.impl.MetaDataAccessorImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Configuration;

import java.util.function.BiFunction;

@Configuration("comSapMtEdmxModelCreator")
//can be exchanged by a bean that parses an edmx mocdel
@ConditionalOnMissingBean(EdmxModelCreator.class)
@ConditionalOnClass(MetaDataAccessorImpl.class)
public class EdmxModelCreator {
    //function: edmx as string,service name => edmx model
    public BiFunction stringToEdmxFunction() {
        //simple default implementation
        return (String edmxAsStr, String serviceName) -> edmxAsStr;
    }

    MetaDataAccessorImpl.EdmxModelCreator stringToModelCreator() {
        return new MetaDataAccessorImpl.EdmxModelCreator() {
            @Override
            public Object parse(String emdx, String serviceName) {
                return emdx;
            }
        };
    }
}