// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/catalog/Catalog.java
// public class Catalog {
// 
// 	private Set<String> applications = new HashSet<>();
// 	private Map<String, List<String>> applicationInstances = new HashMap<>();
// 
// 	Catalog() {
// 	}
// 
// 	public List<String> getApplications() {
// 		return new ArrayList<>(this.applications);
// 	}
// 
// 	void addApplication(String application) {
// 		this.applications.add(application);
// 	}
// 
// 	void removeApplication(String application) {
// 		this.applications.remove(application);
// 	}
// 
// 	void addApplicationInstance(ApplicationInstance applicationInstance) {
// 		this.addApplication(applicationInstance.getApplication());
// 		List<String> instances = this.applicationInstances.getOrDefault(applicationInstance.getApplication(), new ArrayList<>());
// 		instances.add(applicationInstance.getId());
// 		this.applicationInstances.put(applicationInstance.getApplication(), instances);
// 	}
// 
// 	void removeApplicationInstance(ApplicationInstance applicationInstance) {
// 		List<String> instances = this.applicationInstances.getOrDefault(applicationInstance.getApplication(), new ArrayList<>());
// 		instances.remove(applicationInstance.getId());
// 		this.applicationInstances.put(applicationInstance.getApplication(), instances);
// 	}
// 
// 	List<String> getApplicationInstances() {
// 		return this.applicationInstances.values().stream()
// 				.flatMap(List::stream)
// 				.collect(toList());
// 	}
// 
// 	public List<String> getApplicationInstancesForApplication(String application) {
// 		return this.applicationInstances.getOrDefault(application, new ArrayList<>());
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/catalog/CatalogService.java
// public class CatalogService {
// 
// 	private final Catalog catalog;
// 
// 	public CatalogService() {
// 		this.catalog = new Catalog();
// 	}
// 
// 	public Catalog getCatalog() {
// 		return this.catalog;
// 	}
// 
// 	public void addApplicationToCatalog(String application) {
// 		this.catalog.addApplication(application);
// 	}
// 
// 	public void removeApplicationFromCatalog(String application) {
// 		this.catalog.removeApplication(application);
// 	}
// 
// 	public void addApplicationInstanceToCatalog(ApplicationInstance applicationInstance) {
// 		this.catalog.addApplicationInstance(applicationInstance);
// 	}
// 	public void removeApplicationInstanceFromCatalog(ApplicationInstance applicationInstance) {
// 		this.catalog.removeApplicationInstance(applicationInstance);
// 	}
// }


import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import be.ordina.msdashboard.catalog.Catalog;
import be.ordina.msdashboard.catalog.CatalogService;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.api;





/**
 * Controller that exposes the catalog.
 *
 * @author Tim Ysewyn
 */
@ExposesResourceFor(CatalogResource.class)
@RestController
@RequestMapping("/catalog")
public class CatalogController {

// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/catalog/Catalog.java
// public class Catalog {
// 
// 	private Set<String> applications = new HashSet<>();
// 	private Map<String, List<String>> applicationInstances = new HashMap<>();
// 
// 	Catalog() {
// 	}
// 
// 	public List<String> getApplications() {
// 		return new ArrayList<>(this.applications);
// 	}
// 
// 	void addApplication(String application) {
// 		this.applications.add(application);
// 	}
// 
// 	void removeApplication(String application) {
// 		this.applications.remove(application);
// 	}
// 
// 	void addApplicationInstance(ApplicationInstance applicationInstance) {
// 		this.addApplication(applicationInstance.getApplication());
// 		List<String> instances = this.applicationInstances.getOrDefault(applicationInstance.getApplication(), new ArrayList<>());
// 		instances.add(applicationInstance.getId());
// 		this.applicationInstances.put(applicationInstance.getApplication(), instances);
// 	}
// 
// 	void removeApplicationInstance(ApplicationInstance applicationInstance) {
// 		List<String> instances = this.applicationInstances.getOrDefault(applicationInstance.getApplication(), new ArrayList<>());
// 		instances.remove(applicationInstance.getId());
// 		this.applicationInstances.put(applicationInstance.getApplication(), instances);
// 	}
// 
// 	List<String> getApplicationInstances() {
// 		return this.applicationInstances.values().stream()
// 				.flatMap(List::stream)
// 				.collect(toList());
// 	}
// 
// 	public List<String> getApplicationInstancesForApplication(String application) {
// 		return this.applicationInstances.getOrDefault(application, new ArrayList<>());
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/catalog/CatalogService.java
// public class CatalogService {
// 
// 	private final Catalog catalog;
// 
// 	public CatalogService() {
// 		this.catalog = new Catalog();
// 	}
// 
// 	public Catalog getCatalog() {
// 		return this.catalog;
// 	}
// 
// 	public void addApplicationToCatalog(String application) {
// 		this.catalog.addApplication(application);
// 	}
// 
// 	public void removeApplicationFromCatalog(String application) {
// 		this.catalog.removeApplication(application);
// 	}
// 
// 	public void addApplicationInstanceToCatalog(ApplicationInstance applicationInstance) {
// 		this.catalog.addApplicationInstance(applicationInstance);
// 	}
// 	public void removeApplicationInstanceFromCatalog(ApplicationInstance applicationInstance) {
// 		this.catalog.removeApplicationInstance(applicationInstance);
// 	}
// }


// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/api/CatalogController.java
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import be.ordina.msdashboard.catalog.Catalog;
import be.ordina.msdashboard.catalog.CatalogService;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;

/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.api;





/**
 * Controller that exposes the catalog.
 *
 * @author Tim Ysewyn
 */
@ExposesResourceFor(CatalogResource.class)
@RestController
@RequestMapping("/catalog")
public class CatalogController {

	private final CatalogService service;