/**
 * Copyright 2010 OpenEngSB Division, Vienna University of Technology
 *
 * 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 org.openengsb.domains.report.plaintext.internal;

import java.util.Map;

import org.openengsb.core.common.ServiceInstanceFactory;
import org.openengsb.core.common.descriptor.ServiceDescriptor;
import org.openengsb.core.common.descriptor.ServiceDescriptor.Builder;
import org.openengsb.domains.report.ReportDomain;
import org.openengsb.domains.report.common.ReportStoreFactory;

public class PlaintextReportFactory implements ServiceInstanceFactory<ReportDomain, PlaintextReportService> {

    private final ReportStoreFactory storeFactory;

    public PlaintextReportFactory(ReportStoreFactory storeFactory) {
        this.storeFactory = storeFactory;
    }

    @Override
    public ServiceDescriptor getDescriptor(Builder builder) {
        builder.name("reportPlaintext.name").description("reportPlaintext.description");
        return builder.build();
    }

    @Override
    public void updateServiceInstance(PlaintextReportService instance, Map<String, String> attributes) {
        setAttributes(instance, attributes);
    }

    @Override
    public PlaintextReportService createServiceInstance(String id, Map<String, String> attributes) {
        PlaintextReportService service = new PlaintextReportService(id);
        service.setStore(storeFactory.createReportStore(id));
        setAttributes(service, attributes);
        return service;
    }

    private void setAttributes(PlaintextReportService service, Map<String, String> attributes) {
        // do nothing - currently no attributes defined
    }

}

@@ -1393,31 +1393,25 @@
 r.name(%22
-reportP
+p
 laintext
 .name%22).
@@ -1402,16 +1402,22 @@
 laintext
+Report
 .name%22).
@@ -1433,23 +1433,17 @@
 on(%22
-reportP
+p
 laintext
 .des
@@ -1438,16 +1438,22 @@
 laintext
+Report
 .descrip

Fix inconsistency in property naming.