// Path: src/main/java/org/javiermf/features/models/Feature.java
// @Entity
// public class Feature {
// 
//     @Id
//     @GeneratedValue
//     Long id;
// 
//     @Column(nullable = false)
//     String name;
// 
//     @Column
//     String description;
// 
//     @JsonIgnore
//     @ManyToOne
//     Product product;
// 
//     @JsonIgnore
//     @ManyToMany(mappedBy = "activedFeatures")
//     Set<ProductConfiguration> inConfigurations;
// 
//     public static Feature withName(Product product, String featureName) {
//         Feature feature = new Feature();
//         feature.name = featureName;
//         feature.product = product;
//         return feature;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public Product getProduct() {
//         return product;
//     }
// 
//     public void setProduct(Product product) {
//         this.product = product;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (!(o instanceof Feature)) return false;
// 
//         Feature feature = (Feature) o;
// 
//         if (!name.equals(feature.name)) return false;
//         return product.equals(feature.product);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = name.hashCode();
//         result = 31 * result + product.hashCode();
//         return result;
//     }
// }
// 
// Path: src/main/java/org/javiermf/features/services/ProductsService.java
// @Service
// public class ProductsService {
// 
//     @Autowired
//     ProductsDAO productsDAO;
// 
//     @Autowired
//     ProductsConfigurationsDAO productsConfigurationsDAO;
// 
// 
//     public List<String> getAllProductNames() {
//         List<String> allProducts = new ArrayList<String>();
// 
//         for (Product product : productsDAO.findAll()) {
//             allProducts.add(product.getName());
//         }
// 
//         return allProducts;
//     }
// 
//     public Product findByName(String productName) {
//         return productsDAO.findByName(productName);
//     }
// 
//     public void deleteByName(String productName) {
//         productsConfigurationsDAO.deleteConfigurationsForProduct(productName);
//         productsDAO.deleteConstraintsForProduct(productName);
//         productsDAO.deleteByName(productName);
//     }
// 
//     public void add(String productName) {
//         Product product = new Product();
//         product.setName(productName);
//         productsDAO.insert(product);
//     }
// 
//     public Set<Feature> getFeaturesForProduct(String productName) {
//         Product product = findByName(productName);
//         return product.getProductFeatures();
//     }
// 
//     public void addFeatureToProduct(String productName, String featureName, String featureDescription) {
//         Product product = findByName(productName);
//         if (product.hasFeatureNamed(featureName)) {
//             throw new DuplicatedObjectException(featureName);
//         }
//         Feature feature = Feature.withName(product, featureName);
//         feature.setDescription(featureDescription);
//         productsDAO.insertFeature(feature);
//     }
// 
//     @Transactional
//     public Feature updateFeatureOfProduct(String productName, String featureName, String featureDescription) {
//         Product product = productsDAO.findByName(productName);
//         Feature feature = product.findProductFeatureByName(featureName);
//         feature.setDescription(featureDescription);
//         return feature;
//     }
// 
//     @Transactional
//     public void deleteFeatureOfProduct(String productName, String featureName) {
//         Product product = productsDAO.findByName(productName);
//         Feature feature = product.findProductFeatureByName(featureName);
// 
//         for (ProductConfiguration productConfiguration : productsConfigurationsDAO.findConfigurationsWithFeatureActive(feature)) {
//             productConfiguration.getActivedFeatures().remove(feature);
//         }
// 
//         productsDAO.deleteFeature(feature);
//     }
// 
//     public FeatureConstraint addRequiresConstraintToProduct(String productName, String sourceFeatureName, String requiredFeatureName) {
//         Product product = productsDAO.findByName(productName);
// 
//         ConstraintRequires constraintRequires = new ConstraintRequires(sourceFeatureName, requiredFeatureName);
//         constraintRequires.setForProduct(product);
//         productsDAO.insertConstraint(constraintRequires);
// 
//         return constraintRequires;
//     }
// 
//     public void deleteConstraintFromProduct(String productName, Long constraintId) {
//         productsDAO.deleteConstraintForProduct(productName, constraintId);
//     }
// 
//     public FeatureConstraint addExcludesConstraintToProduct(String productName, String sourceFeatureName, String excludedFeatureName) {
//         Product product = productsDAO.findByName(productName);
// 
//         ConstraintExcludes constraintExcludes = new ConstraintExcludes(sourceFeatureName, excludedFeatureName);
//         constraintExcludes.setForProduct(product);
//         productsDAO.insertConstraint(constraintExcludes);
// 
//         return constraintExcludes;
//     }
// }


import org.javiermf.features.models.Feature;
import org.javiermf.features.services.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Set;
package org.javiermf.features.services.rest;



@Component
@Produces("application/json")
public class ProductsFeaturesResource {

    @Autowired
    ProductsService productsService;

    @GET
// Path: src/main/java/org/javiermf/features/models/Feature.java
// @Entity
// public class Feature {
// 
//     @Id
//     @GeneratedValue
//     Long id;
// 
//     @Column(nullable = false)
//     String name;
// 
//     @Column
//     String description;
// 
//     @JsonIgnore
//     @ManyToOne
//     Product product;
// 
//     @JsonIgnore
//     @ManyToMany(mappedBy = "activedFeatures")
//     Set<ProductConfiguration> inConfigurations;
// 
//     public static Feature withName(Product product, String featureName) {
//         Feature feature = new Feature();
//         feature.name = featureName;
//         feature.product = product;
//         return feature;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public Product getProduct() {
//         return product;
//     }
// 
//     public void setProduct(Product product) {
//         this.product = product;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (!(o instanceof Feature)) return false;
// 
//         Feature feature = (Feature) o;
// 
//         if (!name.equals(feature.name)) return false;
//         return product.equals(feature.product);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = name.hashCode();
//         result = 31 * result + product.hashCode();
//         return result;
//     }
// }
// 
// Path: src/main/java/org/javiermf/features/services/ProductsService.java
// @Service
// public class ProductsService {
// 
//     @Autowired
//     ProductsDAO productsDAO;
// 
//     @Autowired
//     ProductsConfigurationsDAO productsConfigurationsDAO;
// 
// 
//     public List<String> getAllProductNames() {
//         List<String> allProducts = new ArrayList<String>();
// 
//         for (Product product : productsDAO.findAll()) {
//             allProducts.add(product.getName());
//         }
// 
//         return allProducts;
//     }
// 
//     public Product findByName(String productName) {
//         return productsDAO.findByName(productName);
//     }
// 
//     public void deleteByName(String productName) {
//         productsConfigurationsDAO.deleteConfigurationsForProduct(productName);
//         productsDAO.deleteConstraintsForProduct(productName);
//         productsDAO.deleteByName(productName);
//     }
// 
//     public void add(String productName) {
//         Product product = new Product();
//         product.setName(productName);
//         productsDAO.insert(product);
//     }
// 
//     public Set<Feature> getFeaturesForProduct(String productName) {
//         Product product = findByName(productName);
//         return product.getProductFeatures();
//     }
// 
//     public void addFeatureToProduct(String productName, String featureName, String featureDescription) {
//         Product product = findByName(productName);
//         if (product.hasFeatureNamed(featureName)) {
//             throw new DuplicatedObjectException(featureName);
//         }
//         Feature feature = Feature.withName(product, featureName);
//         feature.setDescription(featureDescription);
//         productsDAO.insertFeature(feature);
//     }
// 
//     @Transactional
//     public Feature updateFeatureOfProduct(String productName, String featureName, String featureDescription) {
//         Product product = productsDAO.findByName(productName);
//         Feature feature = product.findProductFeatureByName(featureName);
//         feature.setDescription(featureDescription);
//         return feature;
//     }
// 
//     @Transactional
//     public void deleteFeatureOfProduct(String productName, String featureName) {
//         Product product = productsDAO.findByName(productName);
//         Feature feature = product.findProductFeatureByName(featureName);
// 
//         for (ProductConfiguration productConfiguration : productsConfigurationsDAO.findConfigurationsWithFeatureActive(feature)) {
//             productConfiguration.getActivedFeatures().remove(feature);
//         }
// 
//         productsDAO.deleteFeature(feature);
//     }
// 
//     public FeatureConstraint addRequiresConstraintToProduct(String productName, String sourceFeatureName, String requiredFeatureName) {
//         Product product = productsDAO.findByName(productName);
// 
//         ConstraintRequires constraintRequires = new ConstraintRequires(sourceFeatureName, requiredFeatureName);
//         constraintRequires.setForProduct(product);
//         productsDAO.insertConstraint(constraintRequires);
// 
//         return constraintRequires;
//     }
// 
//     public void deleteConstraintFromProduct(String productName, Long constraintId) {
//         productsDAO.deleteConstraintForProduct(productName, constraintId);
//     }
// 
//     public FeatureConstraint addExcludesConstraintToProduct(String productName, String sourceFeatureName, String excludedFeatureName) {
//         Product product = productsDAO.findByName(productName);
// 
//         ConstraintExcludes constraintExcludes = new ConstraintExcludes(sourceFeatureName, excludedFeatureName);
//         constraintExcludes.setForProduct(product);
//         productsDAO.insertConstraint(constraintExcludes);
// 
//         return constraintExcludes;
//     }
// }


// Path: src/main/java/org/javiermf/features/services/rest/ProductsFeaturesResource.java
import org.javiermf.features.models.Feature;
import org.javiermf.features.services.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Set;

package org.javiermf.features.services.rest;



@Component
@Produces("application/json")
public class ProductsFeaturesResource {

    @Autowired
    ProductsService productsService;

    @GET
    public Set<Feature> getFeaturesForProduct(@PathParam("productName") String productName) {