org.eclipse.dirigible.components.odata.service.ODataMetadataService Maven / Gradle / Ivy
/*
* 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.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
import org.apache.olingo.odata2.api.exception.ODataException;
import org.eclipse.dirigible.components.odata.domain.ODataContainer;
import org.eclipse.dirigible.components.odata.domain.ODataSchema;
import org.springframework.stereotype.Service;
/**
* The Class ODataMetadataService.
*/
@Service
public class ODataMetadataService {
/** The odata schema service. */
private final ODataSchemaService odataSchemaService;
/** The odata container service. */
private final ODataContainerService odataContainerService;
/**
* Instantiates a new o data metadata service.
*
* @param odataSchemaService the odata schema service
* @param odataContainerService the odata container service
*/
ODataMetadataService(ODataSchemaService odataSchemaService, ODataContainerService odataContainerService) {
this.odataSchemaService = odataSchemaService;
this.odataContainerService = odataContainerService;
}
/**
* Gets the metadata.
*
* @return the metadata
* @throws ODataException the o data exception
*/
public InputStream getMetadata() throws ODataException {
StringBuilder builder = new StringBuilder();
builder.append("\n");
builder.append(
"\n");
builder.append(
" \n");
List schemas = odataSchemaService.getAll();
for (ODataSchema schema : schemas) {
builder.append(new String(schema.getContent()));
builder.append("\n");
}
builder.append("\n");
builder.append(" \n");
List containers = odataContainerService.getAll();
for (ODataContainer container : containers) {
builder.append(new String(container.getContent()));
builder.append("\n");
}
builder.append(" \n");
builder.append(" \n");
builder.append(" \n");
builder.append(" \n");
return new ByteArrayInputStream(builder.toString()
.getBytes());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy