fixes to accomodate docker creation in ONF - added onap-enabler parent POM, renamed osam-core to osam-core-framework and removed junit that requires connection to DB

Change-Id: Ifdc95438c8b1e5856860882824a11eecac80e19a
Signed-off-by: Aharoni, Pavel (pa0916) <pavel.aharoni@intl.att.com>
diff --git a/osam-core-framework/.mvn/wrapper/maven-wrapper.jar b/osam-core-framework/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..9cc84ea
--- /dev/null
+++ b/osam-core-framework/.mvn/wrapper/maven-wrapper.jar
Binary files differ
diff --git a/osam-core-framework/.mvn/wrapper/maven-wrapper.properties b/osam-core-framework/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..488eeee
--- /dev/null
+++ b/osam-core-framework/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1 @@
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip

diff --git a/osam-core-framework/README.md b/osam-core-framework/README.md
new file mode 100644
index 0000000..f354b71
--- /dev/null
+++ b/osam-core-framework/README.md
@@ -0,0 +1,9 @@
+# OSAM

+```

+docker pull mariadb

+

+docker run --name springbootdb -e MYSQL_DATABASE=osam -e MYSQL_USER=root -e MYSQL_ROOT_PASSWORD=root  -d -p 3306:3306  mariadb

+```

+Restructure:`mvn clean package spring-boot:repackage`

+

+Run:`mvn spring-boot:run -X`

diff --git a/osam-core-framework/api/pom.xml b/osam-core-framework/api/pom.xml
new file mode 100644
index 0000000..0221e6c
--- /dev/null
+++ b/osam-core-framework/api/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>api</artifactId>

+

+    <dependencies>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>model</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>common</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+    </dependencies>

+

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AbstractStorageService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AbstractStorageService.java
new file mode 100644
index 0000000..c7c7375
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AbstractStorageService.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import java.util.List;

+

+public interface AbstractStorageService <K,V>{

+

+    V addOrUpdate(V value);

+

+    void removeById(K key);

+

+    V getById(K key);

+

+    List<V> getAll();

+}

diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AccessPodService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AccessPodService.java
new file mode 100644
index 0000000..da0a9b9
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AccessPodService.java
@@ -0,0 +1,33 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import org.onap.osam.model.dao.AccessPod;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+public interface AccessPodService extends AbstractStorageService<Long, AccessPod>{

+    AccessPod findByPnfId(String pnfId);

+    void removeByPnfId(String pnfId);

+}

diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AlarmService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AlarmService.java
new file mode 100644
index 0000000..5fd8468
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/AlarmService.java
@@ -0,0 +1,43 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import org.onap.osam.model.dao.AlarmsAndEvents;

+import org.onap.osam.model.dao.ActiveAlarmsAndEvents;

+import org.onap.osam.model.dao.HistoricalAlarmsAndEvents;

+

+import java.util.Date;

+import java.util.List;

+

+/**

+ *  basic methods belongs to Active Alarms

+ */

+public interface AlarmService{

+

+    List<ActiveAlarmsAndEvents> getActiveAlarmsAndEventsByDate(Date startDate, Date endDate);

+

+    List<HistoricalAlarmsAndEvents> getHistoricalAlarmsAndEventsByDate(Date startDate, Date endDate);

+

+    void addOrUpdate(AlarmsAndEvents alarmsAndEvents);

+

+}

diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/BroadBandService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/BroadBandService.java
new file mode 100644
index 0000000..7ccaea8
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/BroadBandService.java
@@ -0,0 +1,111 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import org.onap.osam.model.dao.Service;

+import org.onap.osam.model.dao.SpeedProfile;

+import org.onap.osam.model.dao.TechnologyProfile;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public interface BroadBandService {

+    /**

+     *

+     * @param speedProfile

+     */

+    SpeedProfile addSpeedProfile(SpeedProfile speedProfile);

+

+    /**

+     *

+     * @param technologyProfile

+     */

+    TechnologyProfile addTechnologyProfile(TechnologyProfile technologyProfile);

+

+    /**

+     *

+     * @param service

+     */

+    Service addService(Service service);

+

+    /**

+     *

+     * @param id

+     */

+    void removeSpeedProfile(Long id);

+

+    /**

+     *

+     * @param id

+     */

+    void removeTechnologyProfile(Long id);

+

+    /**

+     *

+     * @param id

+     */

+    void removeService(Long id);

+

+    /**

+     *

+     * @param id

+     * @return

+     */

+    SpeedProfile getSpeedProfile(Long id);

+

+    /**

+     *

+     * @param id

+     * @return

+     */

+    TechnologyProfile getTechnologyProfile(Long id);

+

+    /**

+     *

+     * @param id

+     * @return

+     */

+    Service getService(Long id);

+

+    /**

+     *

+     * @return

+     */

+    List<SpeedProfile> getSpeedProfiles();

+

+    /**

+     *

+     * @return

+     */

+    List<TechnologyProfile> getTechnologyProfiles();

+

+    /**

+     *

+     * @return

+     */

+    List<Service> getServices();

+

+}

+

diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/DeviceService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/DeviceService.java
new file mode 100644
index 0000000..921bf66
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/DeviceService.java
@@ -0,0 +1,187 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import org.onap.osam.model.dao.Chassis;

+import org.onap.osam.model.dao.OLTPort;

+import org.onap.osam.model.dao.OLTSlot;

+import org.onap.osam.model.dao.ONTDevice;

+

+import java.util.List;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public interface DeviceService {

+

+     enum OntProvisioningType {

+        PREPROVISION,

+        FULL,

+        PROVISION

+    }

+

+

+/*

+Chassis Related Functionality

+---------------------------------------------------------------------------------------

+*/

+

+    /**

+     *

+     * @param chassis

+     */

+    Chassis addChassis(Chassis chassis);

+

+    /**

+     *

+     * @param id

+     */

+    void deleteChassis(Long id);

+

+    /**

+     *

+     * @param clli

+     */

+    public void deleteChassisByClli(String clli);

+

+    /**

+     *

+     * @param id

+     * @return Chassis

+     */

+    Chassis getChassisById(Long id);

+

+    /**

+     *

+     * @param clli

+     * @return Chassis

+     */

+    Chassis getChassisByClli(String clli);

+

+    /**

+     *

+     * @return Long

+     */

+    Long getChassisCount();

+

+    List<Chassis> getByPnfId(String pnfId);

+

+    List<Chassis> getAllChassis();

+

+/*

+oltSlot Related Functionality

+---------------------------------------------------------------------------------------

+*/

+

+    /**

+     *

+     *

+     * @param oltSlot

+     * @param chassis

+     */

+    OLTSlot addOLTSlot(OLTSlot oltSlot, Chassis chassis);

+

+    /**

+     *

+     * @param id

+     */

+    void deleteOLTSlot(Long id);

+

+    /**

+     *

+     * @param id

+     * @return oltSlot

+     */

+    OLTSlot getOLTSlotById(Long id);

+

+    /**

+     *

+     * @param serialNumber

+     * @return oltSlot

+     */

+    OLTSlot getOLTSlotBySerialNumber(String serialNumber);

+

+

+    /**

+     *

+     * @return all OLT slots

+     */

+    List<OLTSlot> getAllOLTSlots();

+

+/*

+OLTPort Related Functionality

+---------------------------------------------------------------------------------------

+*/

+

+    /**

+     *

+     * @param id

+     */

+    void deleteOLTPort(Long id);

+

+    /**

+     *

+     * @param id

+     * @return OLTPort

+     */

+    OLTPort getOLTPortById(Long id);

+

+/*

+ONTDevice Related Functionality

+---------------------------------------------------------------------------------------

+*/

+

+    /**

+     *

+     * @param ontDevice

+     * @param provisioningType

+     */

+    ONTDevice provisionONTDevice(ONTDevice ontDevice, OntProvisioningType provisioningType);

+

+    /**

+     *

+     * @param id

+     */

+    void deleteONTDevice(Long id);

+

+    /**

+     *

+     * @param id

+     * @return ONTDevice

+     */

+    ONTDevice getONTDeviceById(Long id);

+

+    /**

+     *

+     * @param serialNumber

+     * @return ONTDevice

+     */

+    ONTDevice getONTDeviceBySerialNumber(String serialNumber);

+

+    /**

+     *

+     * @return all ONT devices

+     */

+    List<ONTDevice> getAllONTDevices();

+

+}

diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/PmConfigsService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/PmConfigsService.java
new file mode 100644
index 0000000..40c7dde
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/PmConfigsService.java
@@ -0,0 +1,45 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import org.onap.osam.model.dao.PmConfigs;

+import org.onap.osam.model.dao.PmGroupConfig;

+import org.onap.osam.model.dao.PmConfig;

+

+import java.util.List;

+

+public interface PmConfigsService extends AbstractStorageService<Long,PmConfigs>{

+

+    List<PmConfig> getPmConfigByPmConfigsId(Long pmConfigsId);

+

+    List<PmConfig> getPmConfigByPmConfigGroupId(Long pmGroupConfigsId);

+

+    void addPmGroupConfig(PmConfig pmConfig);

+

+    void addPmGroupConfig(PmGroupConfig pmGroupConfig);

+

+    void removePmConfig(Long pmConfigId);

+

+    void removeGroupPmConfig(Long pmGroupConfigId);

+

+}

diff --git a/osam-core-framework/api/src/main/java/org/onap/osam/api/service/SubscriberService.java b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/SubscriberService.java
new file mode 100644
index 0000000..f71be56
--- /dev/null
+++ b/osam-core-framework/api/src/main/java/org/onap/osam/api/service/SubscriberService.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.api.service;

+

+import org.onap.osam.model.dao.Subscriber;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public interface SubscriberService extends AbstractStorageService<Long,Subscriber> {

+    Subscriber getBySubscriberIdentifier(String userIdentifier);

+}

diff --git a/osam-core-framework/async-jobs/pom.xml b/osam-core-framework/async-jobs/pom.xml
new file mode 100644
index 0000000..ec112e3
--- /dev/null
+++ b/osam-core-framework/async-jobs/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>async-jobs</artifactId>

+    <dependencies>

+        <dependency>

+            <groupId>org.springframework.boot</groupId>

+            <artifactId>spring-boot-starter-quartz</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>core</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.testng</groupId>

+            <artifactId>testng</artifactId>

+            <version>6.14.3</version>

+            <scope>test</scope>

+        </dependency>

+    </dependencies>

+

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/AsyncJobService.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/AsyncJobService.java
new file mode 100644
index 0000000..940bc5f
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/AsyncJobService.java
@@ -0,0 +1,74 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.job;

+

+import org.onap.osam.job.dao.job.JobStatus;

+

+import java.util.List;

+import java.util.UUID;

+

+public interface AsyncJobService {

+

+    JobStatus calcStatus(String asyncRequestStatus);

+

+    List<UUID> pushBulkJob(String userId, boolean isSuccessful, boolean isOLTDependant);

+

+/*

+    List<String> PARAMS_TO_IGNORE = Arrays.asList("vnf_name", "vf_module_name");

+

+    List<ServiceInfo> getAllServicesInfo();

+

+

+    String getServiceInstantiationPath(ServiceInstantiation serviceInstantiationRequest);

+

+    String getOrchestrationRequestsPath();

+

+    ServiceInfo getServiceInfoByJobId(UUID jobUUID);

+

+    List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source);

+

+    ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater);

+

+    ServiceInfo updateServiceInfoAndAuditStatus(UUID jobUuid, Job.JobStatus jobStatus);

+

+    void auditVidStatus(UUID jobUUID, Job.JobStatus jobStatus);

+

+    void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus);

+

+    void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo);

+

+    void handleFailedInstantiation(UUID jobUUID);

+

+    void deleteJob(UUID jobId);

+

+    void hideServiceInfo(UUID jobUUID);

+

+    int getCounterForName(String name);

+

+    int getMaxRetriesGettingFreeNameFromAai();

+

+    void setMaxRetriesGettingFreeNameFromAai(int maxRetriesGettingFreeNameFromAai);

+

+    String getUniqueName(String name, ResourceType resourceType);

+*/

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobCommand.java
new file mode 100644
index 0000000..ca594c0
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobCommand.java
@@ -0,0 +1,61 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job;

+

+import org.onap.osam.job.impl.JobSharedData;

+

+import java.util.Map;

+

+

+/**

+ * A callable instance, with serializable characteristics.

+ * Represents a step in a chain of steps, which eventualy

+ * resides into a packing Job.

+ */

+public interface IJobCommand {

+

+    /**

+     * Initialize the command state

+     * @param sharedData shared data cross all job commands

+     * @param commandData An input to be set into the command. Each implementation may expect different keys in the map.

+     * @return Returns itself

+     */

+    default IJobCommand init(JobSharedData sharedData, Map<String, Object> commandData) {

+        return this;

+    }

+

+    /**

+     * @return Returns the inner state of the command. This state, once passed into init(), should

+     *         bring the command back to it's state.

+     */

+    Map<String, Object> getData();

+

+    /**

+     * Execute the command represented by this instance. Assumes the instance is already init().

+     * @return A NextCommand containing the next command in chain of commands, or null if chain

+     *         should be terminated. Might return itself (packed in a NextCommand).

+     */

+    NextCommand call();

+

+    default JobType getType() {

+        return JobType.jobTypeOf(this.getClass());

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobFactory.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobFactory.java
new file mode 100644
index 0000000..460aba2
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobFactory.java
@@ -0,0 +1,45 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job;

+

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.impl.JobSharedData;

+

+import java.util.Map;

+import java.util.UUID;

+

+/**

+ * kind of factory for creating jobs and converting them to Job Model

+ */

+public interface IJobFactory {

+/*

+    JobModel toModel(Job job);

+*/

+

+    OsamJob createRootJob(JobType jobType, AsyncJobRequest request, String userId, Integer indexInBulk, Map<String, Object> jobData);

+

+    OsamJob createChildJob(JobType jobType, JobStatus jobStatus, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData);

+

+    // Marks types that are an AsyncJob payload

+    interface AsyncJobRequest {

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobsDataAccessService.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobsDataAccessService.java
new file mode 100644
index 0000000..231c057
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/IJobsDataAccessService.java
@@ -0,0 +1,45 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job;

+

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+

+import java.util.Collection;

+import java.util.Optional;

+import java.util.UUID;

+

+public interface IJobsDataAccessService {

+

+    UUID add(OsamJob job);

+

+    Optional<OsamJob> pull(JobStatus topic, String ownerId);

+

+    void pushBack(OsamJob job);

+

+    Collection<OsamJob> peek();

+

+    OsamJob peek(UUID jobId);

+

+    void delete(UUID jobId);

+

+    boolean mute(UUID jobId);

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/JobType.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/JobType.java
new file mode 100644
index 0000000..1cabcad
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/JobType.java
@@ -0,0 +1,57 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job;

+

+import org.onap.osam.job.command.HttpCallCommand;

+import org.onap.osam.job.command.NoOpCommand;

+import org.onap.osam.job.command.WatchingCommand;

+import org.onap.osam.job.command.demo.ChassisCommand;

+import org.onap.osam.job.command.demo.OLTCommand;

+

+import java.util.Map;

+import java.util.stream.Collectors;

+import java.util.stream.Stream;

+

+

+public enum JobType {

+

+    HttpCall(HttpCallCommand.class),

+    Watching(WatchingCommand.class),

+    NoOp(NoOpCommand.class),

+    //Demo

+    ChassisCreation(ChassisCommand.class),

+    OLTCreation(OLTCommand.class);

+

+    private static final Map<Class, JobType> REVERSE_MAP = Stream.of(values())

+            .collect(Collectors.toMap(t -> t.getCommandClass(), t -> t));

+

+    private final Class commandClass;

+

+    <T extends IJobCommand> JobType(Class<T> commandClass) {

+        this.commandClass = commandClass;

+    }

+

+    public Class getCommandClass() {

+        return commandClass;

+    }

+    static JobType jobTypeOf(Class commandClass) {

+        return REVERSE_MAP.get(commandClass);

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/NextCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/NextCommand.java
new file mode 100644
index 0000000..6a61322
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/NextCommand.java
@@ -0,0 +1,46 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job;

+

+import org.onap.osam.job.dao.job.JobStatus;

+

+public class NextCommand {

+    private final JobStatus status;

+    private final IJobCommand command;

+

+    public NextCommand(JobStatus nextStatus, IJobCommand nextCommand) {

+        this.status = nextStatus;

+        this.command = nextCommand;

+    }

+

+    public NextCommand(JobStatus nextStatus) {

+        this.status = nextStatus;

+        this.command = null;

+    }

+

+    public JobStatus getStatus() {

+        return status;

+    }

+

+    public IJobCommand getCommand() {

+        return command;

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/BaseInProgressStatusCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/BaseInProgressStatusCommand.java
new file mode 100644
index 0000000..e1de031
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/BaseInProgressStatusCommand.java
@@ -0,0 +1,142 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import com.google.common.collect.ImmutableMap;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.IJobFactory;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.IJobsDataAccessService;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.AsyncJobService;

+import org.onap.osam.job.impl.JobSharedData;

+import org.onap.osam.job.utils.TimeUtils;

+

+import java.time.ZonedDateTime;

+import java.time.format.DateTimeParseException;

+import java.util.Map;

+

+@Slf4j

+public abstract class BaseInProgressStatusCommand extends CommandBase implements IJobCommand {

+

+    protected AsyncJobService asyncInstantiationBL;

+

+    protected IJobsDataAccessService jobsDataAccessService;

+

+    protected IJobFactory jobAdapter;

+

+/*

+    @Inject

+    protected RestMsoImplementation restMso;

+

+    @Inject

+    protected AuditService auditService;

+*/

+

+    protected String requestId;

+

+    protected String instanceId;

+

+

+    @Override

+    public NextCommand call() {

+

+     //   try {

+            String asyncRequestStatus = getAsyncRequestStatus();

+            //asyncInstantiationBL.auditMsoStatus(getSharedData().getRootJobId(), asyncRequestStatus.get().request);

+            JobStatus jobStatus = asyncInstantiationBL.calcStatus(asyncRequestStatus);

+            ZonedDateTime jobStartTime = getZonedDateTime(asyncRequestStatus);

+            jobStatus = isExpired(jobStartTime) ? JobStatus.FAILED : jobStatus;

+            return processJobStatus(jobStatus);

+

+            //TODO error handling

+  /*      } catch (javax.ws.rs.ProcessingException e) {

+            // Retry when we can't connect MSO during getStatus

+            LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e);

+            return new NextCommand(JobStatus.IN_PROGRESS, this);

+        } catch (BadResponseFromMso e) {

+            return handleFailedMsoResponse(e.getMsoResponse());

+        }

+        catch (RuntimeException e) {

+            LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e);

+            return new NextCommand(JobStatus.STOPPED, this);

+        }*/

+    }

+

+    abstract NextCommand processJobStatus(JobStatus jobStatus);

+

+    abstract boolean isExpired(ZonedDateTime jobStartTime);

+

+    private String getAsyncRequestStatus() {

+/*

+        String path = asyncInstantiationBL.getOrchestrationRequestsPath()+"/"+requestId;

+        RestObject<AsyncRequestStatus> msoResponse = restMso.GetForObject(path, AsyncRequestStatus.class);

+        if (msoResponse.getStatusCode() >= 400 || msoResponse.get() == null) {

+            throw new BadResponseFromMso(msoResponse);

+        }

+*/

+        //TODO

+        return "dummy";

+    }

+

+    /*private NextCommand handleFailedMsoResponse(RestObject<AsyncRequestStatus> msoResponse) {

+        auditService.setFailedAuditStatusFromMso(getSharedData().getJobUuid(), requestId, msoResponse.getStatusCode(), msoResponse.getRaw());

+        LOGGER.error(EELFLoggerDelegate.errorLogger,

+                "Failed to get orchestration status for {}. Status code: {},  Body: {}",

+                requestId, msoResponse.getStatusCode(), msoResponse.getRaw());

+        return new NextCommand(JobStatus.IN_PROGRESS, this);

+    }*/

+

+    @Override

+    public BaseInProgressStatusCommand init(JobSharedData sharedData, Map<String, Object> commandData) {

+        return init(sharedData, (String) commandData.get("requestId"), (String) commandData.get("instanceId"));

+    }

+

+

+    protected BaseInProgressStatusCommand init(JobSharedData sharedData,

+                                               String requestId,

+                                               String instanceId) {

+        init(sharedData);

+        this.requestId = requestId;

+        this.instanceId = instanceId;

+        return this;

+    }

+

+    @Override

+    public Map<String, Object> getData() {

+        return ImmutableMap.of(

+            "requestId", requestId,

+            "instanceId", instanceId

+        );

+    }

+

+    private ZonedDateTime getZonedDateTime(String response) {

+        ZonedDateTime jobStartTime;

+        try {

+            //TODO dummy time until real impl is provided

+            jobStartTime = TimeUtils.parseZonedDateTime(ZonedDateTime.now().toString());

+        } catch (DateTimeParseException | NullPointerException e) {

+            log.error("Failed to parse start time for {}, body: {}. Current time will be used", requestId, response, e);

+            jobStartTime = ZonedDateTime.now();

+        }

+        return jobStartTime;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/BaseWatchingCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/BaseWatchingCommand.java
new file mode 100644
index 0000000..711c27d
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/BaseWatchingCommand.java
@@ -0,0 +1,117 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.AsyncJobService;

+import org.onap.osam.job.impl.JobSharedData;

+import org.onap.osam.job.repository.job.OsamJobRepository;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.util.CollectionUtils;

+

+import java.util.ArrayList;

+import java.util.HashMap;

+import java.util.List;

+import java.util.Map;

+import java.util.UUID;

+import java.util.stream.Collectors;

+

+@Slf4j

+public abstract class BaseWatchingCommand extends CommandBase implements IJobCommand {

+

+    @Autowired

+    protected AsyncJobService asyncInstantiationBL;

+

+    @Autowired

+    private OsamJobRepository osamJobRepository;

+

+    private List<UUID> childrenJobsIds;

+

+    protected boolean isRoot;

+

+    public BaseWatchingCommand() {}

+

+    public BaseWatchingCommand(JobSharedData sharedData, List<UUID> childrenJobsIds, boolean isRoot) {

+        init(sharedData, childrenJobsIds, isRoot);

+    }

+

+    @Override

+    public BaseWatchingCommand init(JobSharedData sharedData, Map<String, Object> commandData) {

+        return init(

+                sharedData,

+                ((List<String>) commandData.get("childrenJobs")).stream().map(x -> UUID.fromString(x)).collect(Collectors.toList()),

+                (boolean) commandData.get("isRoot")

+        );

+    }

+

+    protected BaseWatchingCommand init(JobSharedData sharedData, List<UUID> childrenJobsIds, boolean isRoot) {

+        super.init(sharedData);

+        this.childrenJobsIds = CollectionUtils.isEmpty(childrenJobsIds) ? new ArrayList<>() : childrenJobsIds;

+        this.isRoot = isRoot;

+        return this;

+    }

+

+    @Override

+    public NextCommand call() {

+        Map<UUID, OsamJob> jobs = getAllChildrenJobs();

+

+        boolean isAllChildrenFinal = true;

+        boolean hasFailedChild = false;

+        for (UUID jobId: childrenJobsIds) {

+            OsamJob job = jobs.get(jobId);

+

+

+            //if job not found - we assume it failed

+            if (job == null || job.getStatus() == null) {

+                hasFailedChild = true;

+                continue;

+            }

+

+            if (!job.getStatus().isFinal()) {

+                isAllChildrenFinal = false;

+            } else if (!job.getStatus().equals(JobStatus.COMPLETED)) {

+                //if job status is final - check if it failed status

+                hasFailedChild = true;

+            }

+        }

+

+        return getNextCommand(isAllChildrenFinal, hasFailedChild);

+    }

+

+    private Map<UUID, OsamJob> getAllChildrenJobs() {

+        List<OsamJob> jobs = osamJobRepository.findAllByUuid(childrenJobsIds);

+        return jobs.stream().collect(Collectors.toMap(OsamJob::getUuid, item -> item));

+    }

+

+    protected abstract NextCommand getNextCommand(boolean isAllChildrenFinal, boolean hasFailedChild);

+

+

+    @Override

+    public Map<String, Object> getData() {

+        Map<String, Object> data = new HashMap<>();

+        data.put("childrenJobs", childrenJobsIds);

+        data.put("isRoot", isRoot);

+        return data;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/CommandBase.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/CommandBase.java
new file mode 100644
index 0000000..94c43e7
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/CommandBase.java
@@ -0,0 +1,37 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import lombok.Getter;

+import lombok.Setter;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.job.impl.JobSharedData;

+@Slf4j

+@Getter

+@Setter

+public abstract class CommandBase {

+

+    private JobSharedData sharedData;

+

+    protected CommandBase init(JobSharedData sharedData) {

+        this.setSharedData(sharedData);

+        return this;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/HttpCallCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/HttpCallCommand.java
new file mode 100644
index 0000000..372d751
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/HttpCallCommand.java
@@ -0,0 +1,73 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import com.google.common.collect.ImmutableMap;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.impl.JobSharedData;

+import org.springframework.beans.factory.config.ConfigurableBeanFactory;

+import org.springframework.context.annotation.Scope;

+import org.springframework.http.HttpEntity;

+import org.springframework.stereotype.Component;

+import org.springframework.web.client.RestTemplate;

+

+import java.util.Map;

+import java.util.UUID;

+

+

+@Component

+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)

+public class HttpCallCommand implements IJobCommand {

+    private String url;

+    private UUID uuid;

+

+    public HttpCallCommand() {

+    }

+

+    public HttpCallCommand(String url, UUID uuid) {

+        init(url, uuid);

+    }

+

+    @Override

+    public NextCommand call() {

+        RestTemplate restTemplate = new RestTemplate();

+        HttpEntity<String> request = new HttpEntity<>(new String(uuid.toString()));

+        String str = restTemplate.postForObject(url, request, String.class);

+        return new NextCommand(JobStatus.COMPLETED);

+    }

+

+    @Override

+    public HttpCallCommand init(JobSharedData sharedData, Map<String, Object> commandData) {

+        return init((String) commandData.get("url"), sharedData.getJobUuid());

+    }

+

+    private HttpCallCommand init(String url, UUID jobUuid) {

+        this.url = url;

+        this.uuid = jobUuid;

+        return this;

+    }

+

+    @Override

+    public Map<String, Object> getData() {

+        return ImmutableMap.of("url", url);

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/JobCommandFactory.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/JobCommandFactory.java
new file mode 100644
index 0000000..dc92182
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/JobCommandFactory.java
@@ -0,0 +1,62 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import org.onap.osam.common.exception.GenericUncheckedException;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobCommand;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.context.ApplicationContext;

+import org.springframework.stereotype.Component;

+

+import java.util.function.Function;

+

+@Component

+public class JobCommandFactory {

+

+    final Function<Class<? extends IJobCommand>, IJobCommand> jobFactory;

+

+    @Autowired

+    public JobCommandFactory(ApplicationContext applicationContext) {

+        this.jobFactory = (jobType -> {

+            final Object commandBean = applicationContext.getBean(jobType);

+

+            if (!(commandBean instanceof IJobCommand)) {

+                throw new GenericUncheckedException(commandBean.getClass() + " is not a IJobCommand");

+            }

+

+            return (IJobCommand) commandBean;

+        });

+    }

+

+    public JobCommandFactory(Function<Class<? extends IJobCommand>, IJobCommand> jobFactory) {

+        this.jobFactory = jobFactory;

+    }

+

+    public IJobCommand toCommand(OsamJob job) {

+

+        final IJobCommand command = jobFactory.apply(job.getType().getCommandClass());

+        command.init(job.getSharedData(), job.getDataMap());

+

+        return command;

+    }

+

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/NoOpCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/NoOpCommand.java
new file mode 100644
index 0000000..8f110a1
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/NoOpCommand.java
@@ -0,0 +1,44 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.NextCommand;

+import org.springframework.beans.factory.config.ConfigurableBeanFactory;

+import org.springframework.context.annotation.Scope;

+import org.springframework.stereotype.Component;

+

+import java.util.Collections;

+import java.util.Map;

+

+@Component

+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)

+public class NoOpCommand implements IJobCommand {

+

+    @Override

+    public NextCommand call() {

+        return null;

+    }

+

+    @Override

+    public Map<String, Object> getData() {

+        return Collections.emptyMap();

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/WatchingCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/WatchingCommand.java
new file mode 100644
index 0000000..70b9f00
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/WatchingCommand.java
@@ -0,0 +1,54 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.impl.JobSharedData;

+import org.springframework.beans.factory.config.ConfigurableBeanFactory;

+import org.springframework.context.annotation.Scope;

+import org.springframework.stereotype.Component;

+

+import java.util.List;

+import java.util.UUID;

+

+@Component

+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)

+public class WatchingCommand extends BaseWatchingCommand {

+

+    public WatchingCommand() {}

+

+    public WatchingCommand(JobSharedData sharedData, List<UUID> childrenJobsIds, boolean isRoot) {

+        super(sharedData, childrenJobsIds, isRoot);

+    }

+

+    protected NextCommand getNextCommand(boolean isAllChildrenFinal, boolean hasFailedChild) {

+        if (isAllChildrenFinal) {

+            JobStatus jobStatus = hasFailedChild ?  JobStatus.COMPLETED_WITH_ERRORS : JobStatus.COMPLETED;

+            return new NextCommand(jobStatus);

+        } else {

+            if (isRoot) {

+                return new NextCommand(JobStatus.IN_PROGRESS, this);

+            }

+            return new NextCommand(JobStatus.RESOURCE_IN_PROGRESS, this);

+        }

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/demo/ChassisCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/demo/ChassisCommand.java
new file mode 100644
index 0000000..98de930
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/demo/ChassisCommand.java
@@ -0,0 +1,108 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command.demo;

+

+import com.google.common.collect.ImmutableMap;

+import com.google.common.collect.Lists;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.job.command.WatchingCommand;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.JobType;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.command.CommandBase;

+import org.onap.osam.job.impl.DummyAsyncRequest;

+import org.onap.osam.job.impl.JobFactory;

+import org.onap.osam.job.impl.JobSharedData;

+import org.onap.osam.job.impl.JobsDataAccessService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.beans.factory.config.ConfigurableBeanFactory;

+import org.springframework.context.annotation.Scope;

+import org.springframework.stereotype.Component;

+

+import java.util.List;

+import java.util.Map;

+import java.util.UUID;

+

+@Slf4j

+@Component

+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)

+

+/**

+ * In this example, Chassis job is successful and spawns off OLT job - without being dependent on it.

+ */

+

+public class ChassisCommand extends CommandBase implements IJobCommand {

+

+    private Boolean isSuccessful;

+

+    private Boolean isOltDependant;

+

+    @Autowired

+    protected JobsDataAccessService jobsDataAccessService;

+

+    @Autowired

+    protected JobFactory jobFactory;

+

+    public ChassisCommand(){}

+

+    @Override

+    public IJobCommand init(JobSharedData sharedData, Map<String, Object> commandData) {

+        super.init(sharedData);

+        isSuccessful = (Boolean) commandData.get("isSuccessful");

+        isOltDependant = (Boolean) commandData.get("isOltDependant");

+        return this;

+    }

+

+    @Override

+    public Map<String, Object> getData() {

+        return ImmutableMap.of("isSuccessful", isSuccessful,

+                "isOltDependant", isOltDependant);

+    }

+

+    @Override

+    public NextCommand call() {

+        NextCommand nextCommand;

+        if (isSuccessful){

+            log.debug("ChassisCommand - it's your LUCKY day! :) ChassisCreation created, continuing to OLTCreation...");

+

+            //Adding an OLTCreation child job

+            final List<UUID> oltChildJobs = getOltChildJobs();

+

+            if (isOltDependant){

+                log.debug("ChassisCommand - OLT Dependent scenario. Pending to wait if OLT job succeeds before deciding if Chassis job succeeds.");

+                nextCommand = new NextCommand(JobStatus.PENDING, new WatchingCommand(getSharedData(), oltChildJobs, true));

+            } else {

+                log.debug("ChassisCommand - independent scenario. This job is completed, regardless of child OLT job.");

+                nextCommand = new NextCommand(JobStatus.COMPLETED);

+            }

+         } else {

+            log.debug("ChassisCommand - it's your UNLUCKY day! :( ChassisCreation creation failed, your bulk request is finished here.");

+            nextCommand = new NextCommand(JobStatus.FAILED);

+        }

+        return nextCommand;

+    }

+

+    private List<UUID> getOltChildJobs() {

+        log.debug("Spinning off OLT child job....");

+        Map<String, Object> dataForOLTChild = ImmutableMap.of();

+        return Lists.newArrayList(jobsDataAccessService.add(jobFactory.createChildJob(JobType.OLTCreation, JobStatus.CREATING, new DummyAsyncRequest(), getSharedData(), ImmutableMap.of())));

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/demo/OLTCommand.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/demo/OLTCommand.java
new file mode 100644
index 0000000..4de73ad
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/command/demo/OLTCommand.java
@@ -0,0 +1,48 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command.demo;

+

+import com.google.common.collect.ImmutableMap;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.command.CommandBase;

+import org.springframework.beans.factory.config.ConfigurableBeanFactory;

+import org.springframework.context.annotation.Scope;

+import org.springframework.stereotype.Component;

+

+import java.util.Map;

+

+@Slf4j

+@Component

+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)

+public class OLTCommand extends CommandBase implements IJobCommand {

+    @Override

+    public Map<String, Object> getData() {

+        return ImmutableMap.of();

+    }

+

+    @Override

+    public NextCommand call() {

+        log.debug("OLTCreation Command - for this demo, I'm always successful!!");

+        return new NextCommand(JobStatus.COMPLETED);

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/dao/job/JobStatus.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/dao/job/JobStatus.java
new file mode 100644
index 0000000..c3b031f
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/dao/job/JobStatus.java
@@ -0,0 +1,40 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.dao.job;

+

+public enum JobStatus {

+    COMPLETED(true),

+    FAILED(true),

+    IN_PROGRESS(false),

+    RESOURCE_IN_PROGRESS(false),

+    PAUSE(false),

+    PENDING(false),

+    STOPPED(true),

+    COMPLETED_WITH_ERRORS(true),

+    CREATING(false);

+

+    private final Boolean finalStatus;

+    public Boolean isFinal(){return finalStatus;}

+

+    JobStatus(Boolean finalStatus)

+    {

+        this.finalStatus = finalStatus ;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/dao/job/OsamJob.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/dao/job/OsamJob.java
new file mode 100644
index 0000000..807221f
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/dao/job/OsamJob.java
@@ -0,0 +1,181 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.dao.job;

+

+

+import com.fasterxml.jackson.core.JsonProcessingException;

+import com.fasterxml.jackson.databind.ObjectMapper;

+import com.google.common.base.MoreObjects;

+import lombok.Getter;

+import lombok.Setter;

+import lombok.extern.slf4j.Slf4j;

+import org.hibernate.annotations.DynamicUpdate;

+import org.hibernate.annotations.SelectBeforeUpdate;

+import org.hibernate.annotations.Type;

+import org.onap.osam.job.JobType;

+import org.onap.osam.job.impl.JobData;

+import org.onap.osam.job.impl.JobSharedData;

+import org.onap.osam.model.dao.BaseEntity;

+import org.springframework.data.annotation.CreatedDate;

+import org.springframework.data.annotation.LastModifiedDate;

+

+import javax.persistence.AttributeConverter;

+import javax.persistence.Column;

+import javax.persistence.Converter;

+import javax.persistence.Entity;

+import javax.persistence.EnumType;

+import javax.persistence.Enumerated;

+import javax.persistence.Lob;

+import java.io.IOException;

+import java.util.Date;

+import java.util.Map;

+import java.util.Objects;

+import java.util.UUID;

+

+/*

+ The following 2 annotations let hibernate to update only fields that actually have been changed.

+ DynamicUpdate tell hibernate to update only dirty fields.

+ SelectBeforeUpdate is needed since during update the entity is detached (get and update are in different sessions)

+*/

+@DynamicUpdate()

+@SelectBeforeUpdate()

+@Entity

+@Getter

+@Setter

+@Slf4j

+public class OsamJob extends BaseEntity {

+

+    @Column(unique = true, nullable = false, columnDefinition = "CHAR(36)")

+    @Type(type="org.hibernate.type.UUIDCharType")

+    private UUID uuid;

+

+    @CreatedDate

+    private Date createdDate;

+

+    @LastModifiedDate

+    private Date modifiedDate;

+

+    @Enumerated(value = EnumType.STRING)

+    private JobStatus status;

+

+    @Enumerated(value = EnumType.STRING)

+    private JobType type;

+

+    @Lob

+    @Column

+    private JobData data = new JobData();

+

+    @Column

+    private String takenBy;

+

+    @Column

+    private String userId;

+

+    @Column(nullable = false)

+    private Integer age = 0;

+

+    @Column(nullable = false)

+    private Integer indexInBulk = 0;

+

+    @Column

+    private Date deletedAt;

+

+    public Map<String, Object> getDataMap() {

+        return data.getCommandData().get(getType());

+    }

+

+    public void setTypeAndData(JobType jobType, Map<String, Object> data) {

+        // *add* the data to map,

+        // then change state to given type

+        this.type = jobType;

+        this.data.getCommandData().put(jobType, data);

+    }

+

+    public void setSharedData(JobSharedData sharedData) {

+        this.data.setSharedData(sharedData);

+    }

+

+    public JobSharedData getSharedData(){

+        return this.data.getSharedData();

+    };

+

+    @Override

+    public boolean equals(Object o) {

+        if (this == o) return true;

+        if (!(o instanceof OsamJob)) return false;

+        OsamJob daoJob = (OsamJob) o;

+        return Objects.equals(getUuid(), daoJob.getUuid());

+    }

+

+    @Override

+    public int hashCode() {

+        return Objects.hash(getUuid());

+    }

+

+    @Override

+    public String toString() {

+        return MoreObjects.toStringHelper(this)

+                .add("status", status)

+                .add("type", type)

+                .add("uuid", uuid)

+                .add("takenBy", takenBy)

+                .add("userId", userId)

+                .add("age", age)

+                .add("createdDate", createdDate)

+                .add("modifiedDate", modifiedDate)

+                .add("deletedAt", deletedAt)

+                .add("data", data)

+                .toString();

+    }

+

+    @Converter(autoApply = true)

+    public static class JobDataConverter implements AttributeConverter<JobData, String> {

+

+        @Override

+        public String convertToDatabaseColumn(JobData jobData) {

+            if( jobData == null )

+                return null;

+

+            ObjectMapper mapper = new ObjectMapper();

+

+            try {

+                return mapper.writeValueAsString(jobData);

+            } catch (JsonProcessingException e) {

+                log.error("Couldn't persist JobData object {}, error: {}. Persisting null", jobData, e);

+                return null;

+            }

+        }

+

+        @Override

+        public JobData convertToEntityAttribute(String s) {

+            if( s == null )

+                return null;

+

+            ObjectMapper mapper = new ObjectMapper();

+

+            try {

+                return mapper.readValue(s, JobData.class);

+            } catch (IOException e) {

+                log.error("Couldn't deserialize {} to JobData object, error: {}. Returning null", s, e);

+                return null;

+            }

+        }

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/exceptions/JobException.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/exceptions/JobException.java
new file mode 100644
index 0000000..46ba80e
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/exceptions/JobException.java
@@ -0,0 +1,35 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.exceptions;

+

+import java.util.UUID;

+

+public class JobException extends RuntimeException {

+    private final UUID jobUuid;

+

+    public JobException(String message, UUID jobUuid, Throwable cause) {

+        super(message, cause);

+        this.jobUuid = jobUuid;

+    }

+

+    public UUID getJobUuid() {

+        return jobUuid;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/AsyncJobServiceImpl.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/AsyncJobServiceImpl.java
new file mode 100644
index 0000000..c964f01
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/AsyncJobServiceImpl.java
@@ -0,0 +1,506 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.job.impl;

+

+import com.google.common.collect.ImmutableMap;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.AsyncJobService;

+import org.onap.osam.job.JobType;

+import org.springframework.stereotype.Service;

+

+import java.util.ArrayList;

+import java.util.Calendar;

+import java.util.Date;

+import java.util.List;

+import java.util.Map;

+import java.util.UUID;

+

+@Service

+public class AsyncJobServiceImpl implements AsyncJobService {

+

+    private final JobFactory jobFactory;

+

+    private final JobsDataAccessService jobsDataAccessService;

+

+    private Map<String, JobStatus> msoStateToJobStatusMap = ImmutableMap.<String, JobStatus>builder()

+            .put("inprogress", JobStatus.IN_PROGRESS)

+            .put("failed", JobStatus.FAILED)

+            .put("pause", JobStatus.PAUSE)

+            .put("paused", JobStatus.PAUSE)

+            .put("complete", JobStatus.COMPLETED)

+            .put("pending", JobStatus.IN_PROGRESS)

+            .put("pendingmanualtask", JobStatus.PAUSE)

+            .put("unlocked", JobStatus.IN_PROGRESS)

+            .build();

+

+

+    public AsyncJobServiceImpl(JobFactory jobFactory, JobsDataAccessService jobsDataAccessService) {

+        this.jobFactory = jobFactory;

+        this.jobsDataAccessService = jobsDataAccessService;

+    }

+

+    @Override

+    public JobStatus calcStatus(String asyncRequestStatus) {

+        JobStatus jobStatus = msoStateToJobStatusMap.get(asyncRequestStatus);

+        return (jobStatus != null ? jobStatus : JobStatus.IN_PROGRESS);

+    }

+

+    @Override

+    public List<UUID> pushBulkJob(String userId, boolean isSuccessful, boolean isOltDependant) {

+        List<UUID> uuids = new ArrayList<>();

+        Date createdBulkDate = Calendar.getInstance().getTime();

+        int bulkSize = 1;

+        for (int i = 0; i < bulkSize; i++) {

+            OsamJob job = jobFactory.createRootJob(JobType.ChassisCreation, new DummyAsyncRequest(), userId, i,

+                    ImmutableMap.of("isSuccessful", isSuccessful, "isOltDependant", isOltDependant));

+            UUID jobId = jobsDataAccessService.add(job);

+            uuids.add(jobId);

+        }

+        return uuids;

+    }

+

+

+

+/*

+    private final DataAccessService dataAccessService;

+

+    private final IJobFactory jobAdapter;

+

+    private final IJobsDataAccessService jobService;

+

+    private SessionFactory sessionFactory;

+

+    private AaiClientInterface aaiClient;

+

+    private int maxRetriesGettingFreeNameFromAai = MAX_RETRIES_GETTING_FREE_NAME_FROM_AAI;

+

+    private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AsyncInstantiationBusinessLogicImpl.class);

+

+

+

+    @Autowired

+    public AsyncInstantiationBusinessLogicImpl(DataAccessService dataAccessService,

+                                               IJobFactory jobAdapter,

+                                               IJobsDataAccessService jobService,

+                                               SessionFactory sessionFactory,

+                                               AaiClientInterface aaiClient) {

+        this.dataAccessService = dataAccessService;

+        this.jobAdapter = jobAdapter;

+        this.jobService = jobService;

+        this.sessionFactory = sessionFactory;

+        this.aaiClient = aaiClient;

+    }

+

+    @Override

+    public List<ServiceInfo> getAllServicesInfo() {

+        return dataAccessService.getList(ServiceInfo.class, filterByCreationDateAndNotDeleted(), orderByCreatedDateAndStatus(), null);

+    }

+

+    private String filterByCreationDateAndNotDeleted() {

+        LocalDateTime minus3Months = LocalDateTime.now().minusMonths(3);

+        Timestamp filterDate = Timestamp.valueOf(minus3Months);

+        return " where" +

+                "   hidden = false" +

+                "   and deleted_at is null" +  // don't fetch deleted

+                "   and created >= '" + filterDate + "' ";

+    }

+

+    private String orderByCreatedDateAndStatus() {

+        return " createdBulkDate DESC ,\n" +

+                "  (CASE jobStatus\n" +

+                "   WHEN 'COMPLETED' THEN 0\n" +

+                "   WHEN 'FAILED' THEN 0\n" +

+                "   WHEN 'IN_PROGRESS' THEN 1\n" +

+                "   WHEN 'PAUSE' THEN 2\n" +

+                "   WHEN 'PENDING' THEN 3\n" +

+                "   WHEN 'STOPPED' THEN 3 END),\n" +

+                "  statusModifiedDate ";

+    }

+

+    @Override

+    public List<UUID> pushBulkJob(ServiceInstantiation request, String userId) {

+        List<UUID> uuids = new ArrayList<>();

+        Date createdBulkDate = Calendar.getInstance().getTime();

+        int bulkSize = request.getBulkSize();

+        UUID templateId = UUID.randomUUID();

+        for (int i = 0; i < bulkSize; i++) {

+            //Job job = jobAdapter.createJob(JobType.ServiceInstantiation, request, templateId, userId, i);

+            Job job = jobAdapter.createJob(JobType.NoOp, request, templateId, userId, i);//should be some instatiation, this was changed as part of code cleaning

+

+            UUID jobId = jobService.add(job);

+            auditVidStatus(jobId,getStatus());

+            uuids.add(jobId);

+            dataAccessService.saveDomainObject(createServiceInfo(userId, request, jobId, templateId, createdBulkDate), DaoUtils.getPropsMap());

+        }

+        return uuids;

+    }

+

+    private ServiceInfo createServiceInfo(String userId, ServiceInstantiation serviceInstantiation, UUID jobId, UUID templateId, Date createdBulkDate) {

+        return new ServiceInfo(

+                userId, JobStatus.PENDING, serviceInstantiation.isPause(), jobId, templateId,

+                serviceInstantiation.getOwningEntityId(),

+                serviceInstantiation.getOwningEntityName(),

+                serviceInstantiation.getProjectName(),

+                serviceInstantiation.getAicZoneId(),

+                serviceInstantiation.getAicZoneName(),

+                serviceInstantiation.getTenantId(),

+                serviceInstantiation.getTenantName(),

+                serviceInstantiation.getLcpCloudRegionId(),

+                null,

+                serviceInstantiation.getSubscriptionServiceType(),

+                serviceInstantiation.getSubscriberName(),

+                null,

+                serviceInstantiation.getInstanceName(),

+                serviceInstantiation.getModelInfo().getModelInvariantId(),

+                serviceInstantiation.getModelInfo().getModelName(),

+                serviceInstantiation.getModelInfo().getModelVersion(),

+                createdBulkDate

+        );

+    }

+

+

+    */

+/*//*

+/@Override

+    public RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest(UUID jobId, ServiceInstantiation payload, String userId) {

+

+           ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity owningEntity = new ServiceInstantiationRequestDetails.ServiceInstantiationOwningEntity(payload.getOwningEntityId(), payload.getOwningEntityName());

+

+        SubscriberInfo subscriberInfo = new SubscriberInfo();

+        subscriberInfo.setGlobalSubscriberId(payload.getGlobalSubscriberId());

+

+        String serviceInstanceName = null;

+        if(payload.isUserProvidedNaming()) {

+            serviceInstanceName = getUniqueName(payload.getInstanceName(), ResourceType.SERVICE_INSTANCE);

+            String finalServiceInstanceName = serviceInstanceName;

+            updateServiceInfo(jobId, x -> x.setServiceInstanceName(finalServiceInstanceName));

+        }

+        ServiceInstantiationRequestDetails.RequestInfo requestInfo = new ServiceInstantiationRequestDetails.RequestInfo(

+                serviceInstanceName,

+                payload.getProductFamilyId(),

+                "VID",

+                payload.isRollbackOnFailure(),

+                userId);

+

+        List<ServiceInstantiationRequestDetails.ServiceInstantiationService> serviceInstantiationService = new LinkedList<>();

+        List<Map<String, String>> unFilteredInstanceParams = payload.getInstanceParams() != null ? payload.getInstanceParams() : new LinkedList<>();

+        List<Map<String, String>> filteredInstanceParams = removeUnNeededParams(unFilteredInstanceParams);

+        ServiceInstantiationRequestDetails.ServiceInstantiationService serviceInstantiationService1 = new ServiceInstantiationRequestDetails.ServiceInstantiationService(

+                payload.getModelInfo(),

+                serviceInstanceName,

+                filteredInstanceParams,

+                createServiceInstantiationVnfList(payload)

+        );

+        serviceInstantiationService.add(serviceInstantiationService1);

+

+        ServiceInstantiationRequestDetails.RequestParameters requestParameters = new ServiceInstantiationRequestDetails.RequestParameters(payload.getSubscriptionServiceType(), false, serviceInstantiationService);

+

+        ServiceInstantiationRequestDetails.Project project = payload.getProjectName() != null ?  new ServiceInstantiationRequestDetails.Project(payload.getProjectName()) : null;

+

+        ServiceInstantiationRequestDetails requestDetails = new ServiceInstantiationRequestDetails(payload.getModelInfo(), owningEntity, subscriberInfo,

+                project, requestInfo, requestParameters);

+

+        RequestDetailsWrapper<ServiceInstantiationRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper(requestDetails);

+        debugRequestDetails(requestDetailsWrapper, logger);

+        return requestDetailsWrapper;

+    }*//*

+

+

+    private List<Map<String, String>> removeUnNeededParams(List<Map<String, String>> instanceParams) {

+        List<String> keysToRemove = new ArrayList<>();

+        if (instanceParams != null && !instanceParams.isEmpty()) {

+            for (String key : instanceParams.get(0).keySet()) {

+                for (String paramToIgnore : PARAMS_TO_IGNORE)

+                    if ((key.equalsIgnoreCase(paramToIgnore))) {

+                        keysToRemove.add(key);

+                    }

+            }

+            for (String key : keysToRemove) {

+                instanceParams.get(0).remove(key);

+            }

+            //TODO will be removed on once we stop using List<Map<String, String>>

+            if (instanceParams.get(0).isEmpty()) {

+                return Collections.emptyList();

+            }

+        }

+        return instanceParams;

+    }

+

+    private ServiceInstantiationRequestDetails.ServiceInstantiationVnfList createServiceInstantiationVnfList(ServiceInstantiation payload) {

+        CloudConfiguration cloudConfiguration = new CloudConfiguration();

+        cloudConfiguration.setTenantId(payload.getTenantId());

+        cloudConfiguration.setLcpCloudRegionId(payload.getLcpCloudRegionId());

+

+        Map<String, Vnf> vnfs = payload.getVnfs();

+        List<ServiceInstantiationRequestDetails.ServiceInstantiationVnf> vnfList = new ArrayList<>();

+        for (Vnf vnf : vnfs.values()) {

+            Map<String, Map<String, VfModule>> vfModules = vnf.getVfModules();

+            List<VfModule> convertedUnFilteredVfModules = convertVfModuleMapToList(vfModules);

+            List<VfModule> filteredVfModules = filterInstanceParamsFromVfModuleAndUniqueNames(convertedUnFilteredVfModules, vnf.isUserProvidedNaming());

+            ServiceInstantiationRequestDetails.ServiceInstantiationVnf serviceInstantiationVnf = new ServiceInstantiationRequestDetails.ServiceInstantiationVnf(

+                    vnf.getModelInfo(),

+                    cloudConfiguration,

+                    vnf.getPlatformName(),

+                    vnf.getLineOfBusiness(),

+                    payload.getProductFamilyId(),

+                    removeUnNeededParams(vnf.getInstanceParams()),

+                    filteredVfModules,

+                    vnf.isUserProvidedNaming() ? getUniqueName(vnf.getInstanceName(), ResourceType.GENERIC_VNF) : null

+            );

+            vnfList.add(serviceInstantiationVnf);

+        }

+

+        return new ServiceInstantiationRequestDetails.ServiceInstantiationVnfList(vnfList);

+    }

+

+    private List<VfModule> convertVfModuleMapToList(Map<String, Map<String, VfModule>> vfModules) {

+        return vfModules.values().stream().flatMap(vfModule -> vfModule.values().stream()).collect(Collectors.toList());

+    }

+

+    private List<VfModule> filterInstanceParamsFromVfModuleAndUniqueNames(List<VfModule> unFilteredVfModules, boolean isUserProvidedNaming) {

+        return unFilteredVfModules.stream().map(vfModule ->

+                new VfModule(

+                        vfModule.getModelInfo(),

+                        getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getInstanceName(), ResourceType.VF_MODULE),

+                        getUniqueNameIfNeeded(isUserProvidedNaming, vfModule.getVolumeGroupInstanceName(), ResourceType.VOLUME_GROUP),

+                        removeUnNeededParams(vfModule.getInstanceParams())))

+                .collect(Collectors.toList());

+    }

+

+    private String getUniqueNameIfNeeded(boolean isUserProvidedNaming, String name, ResourceType resourceType) {

+        return isUserProvidedNaming && !StringUtils.isEmpty(name) ?

+                getUniqueName(name, resourceType) : null;

+    }

+

+    @Override

+    public String getServiceInstantiationPath(ServiceInstantiation serviceInstantiationRequest) {

+        //in case pause flag is true - use assign , else - use create.

+        return MsoBusinessLogicImpl.validateEndpointPath(

+                serviceInstantiationRequest.isPause() ?

+                        "mso.restapi.serviceInstanceAssign" : "mso.restapi.serviceInstanceCreate"

+        );

+    }

+

+    @Override

+    public String getOrchestrationRequestsPath() {

+        return MsoBusinessLogicImpl.validateEndpointPath(MsoProperties.MSO_REST_API_GET_ORC_REQ);

+    }

+

+    @Override

+    public ServiceInfo updateServiceInfo(UUID jobUUID, Consumer<ServiceInfo> serviceUpdater) {

+        ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID);

+        serviceUpdater.accept(serviceInfo);

+        dataAccessService.saveDomainObject(serviceInfo, DaoUtils.getPropsMap());

+        return serviceInfo;

+    }

+

+

+

+    private void setServiceInfoStatus(ServiceInfo serviceInfo, JobStatus jobStatus) {

+        serviceInfo.setJobStatus(jobStatus);

+        serviceInfo.setStatusModifiedDate(new Date());

+    }

+

+    public ServiceInfo getServiceInfoByJobId(UUID jobUUID) {

+        List<ServiceInfo> serviceInfoList = dataAccessService.getList(ServiceInfo.class, String.format(" where jobId = '%s' ", jobUUID), null, null);

+        if (serviceInfoList.size() != 1) {

+            throw new GenericUncheckedException("Failed to retrieve job with uuid " + jobUUID + " from ServiceInfo table. Instances found: " + serviceInfoList.size());

+        }

+        return serviceInfoList.get(0);

+    }

+

+    public List<JobAuditStatus> getAuditStatuses(UUID jobUUID, JobAuditStatus.SourceStatus source) {

+        return dataAccessService.getList(

+            JobAuditStatus.class,

+            String.format(" where SOURCE = '%s' and JOB_ID = '%s'",source, jobUUID),

+            " CREATED_DATE ", null);

+    }

+

+    private JobAuditStatus getLatestAuditStatus(UUID jobUUID, JobAuditStatus.SourceStatus source){

+        List<JobAuditStatus> list = getAuditStatuses(jobUUID,source);

+        return !list.isEmpty() ? list.get(list.size()-1) : null;

+    }

+

+    @Override

+    public void auditVidStatus(UUID jobUUID, JobStatus jobStatus){

+        JobAuditStatus vidStatus = new JobAuditStatus(jobUUID, jobStatus.toString(), JobAuditStatus.SourceStatus.VID);

+        auditStatus(vidStatus);

+    }

+

+    @Override

+    public void auditMsoStatus(UUID jobUUID, AsyncRequestStatus.Request msoRequestStatus){

+        auditMsoStatus(jobUUID, msoRequestStatus.requestStatus.getRequestState(), msoRequestStatus.requestId, msoRequestStatus.requestStatus.getStatusMessage());

+    }

+

+    @Override

+    public void auditMsoStatus(UUID jobUUID, String jobStatus, String requestId, String additionalInfo){

+        JobAuditStatus msoStatus = new JobAuditStatus(jobUUID, jobStatus, JobAuditStatus.SourceStatus.MSO,

+                requestId != null ? UUID.fromString(requestId) : null,

+                additionalInfo);

+        auditStatus(msoStatus);

+    }

+

+    private void auditStatus(JobAuditStatus jobAuditStatus){

+        JobAuditStatus latestStatus = getLatestAuditStatus(jobAuditStatus.getJobId(),jobAuditStatus.getSource());

+        if (latestStatus == null || !latestStatus.equals(jobAuditStatus))

+            dataAccessService.saveDomainObject(jobAuditStatus, DaoUtils.getPropsMap());

+

+    }

+

+

+

+    @Override

+    public void handleFailedInstantiation(UUID jobUUID) {

+        ServiceInfo serviceInfo = updateServiceInfoAndAuditStatus(jobUUID, JobStatus.FAILED);

+        List<ServiceInfo> serviceInfoList = dataAccessService.getList(

+                ServiceInfo.class,

+                String.format(" where templateId = '%s' and jobStatus = '%s'",

+                        serviceInfo.getTemplateId(),

+                        JobStatus.PENDING),

+                null, null);

+        serviceInfoList.forEach(si -> updateServiceInfoAndAuditStatus(si.getJobId(), JobStatus.STOPPED));

+    }

+

+    @Override

+    public void deleteJob(UUID jobId) {

+        jobService.delete(jobId);

+        Date now = new Date();

+        updateServiceInfo(jobId, x -> x.setDeletedAt(now));

+    }

+

+    @Override

+    public void hideServiceInfo(UUID jobUUID) {

+        ServiceInfo serviceInfo = getServiceInfoByJobId(jobUUID);

+        if (!serviceInfo.getJobStatus().isFinal()) {

+            String message = String.format( "jobId %s: Service status does not allow hide service, status = %s",

+                    serviceInfo.getJobId(),

+                    serviceInfo.getJobStatus());

+            logger.error(EELFLoggerDelegate.errorLogger, message);

+            throw new OperationNotAllowedException(message);

+        }

+        serviceInfo.setHidden(true);

+        dataAccessService.saveDomainObject(serviceInfo, DaoUtils.getPropsMap());

+    }

+

+    @Override

+    public int

+

+

+    getCounterForName(String name) {

+

+        String hqlSelectNC = "from NameCounter where name = :name";

+        String hqlUpdateCounter = "update NameCounter set counter = :newCounter " +

+                "where name= :name " +

+                "and counter= :prevCounter";

+

+        Integer counter = null;

+        GenericUncheckedException lastException = null;

+        for (int i = 0; i< MAX_RETRIES_GETTING_COUNTER && counter==null; i++) {

+            try {

+                counter = calcCounter(name, hqlSelectNC, hqlUpdateCounter);

+            }

+            catch (GenericUncheckedException exception) {

+                lastException = exception; //do nothing, we will try again in the loop

+            }

+        }

+

+        if (counter!=null) {

+            return counter;

+        }

+

+        throw lastException!=null ? new DbFailureUncheckedException(lastException) :

+                new DbFailureUncheckedException("Failed to get counter for "+name+" due to unknown error");

+

+    }

+

+    private Integer calcCounter(String name, String hqlSelectNC, String hqlUpdateCounter) {

+        Integer counter;

+        counter = DaoUtils.tryWithSessionAndTransaction(sessionFactory, session -> {

+            NameCounter nameCounter = (NameCounter) session.createQuery(hqlSelectNC)

+                    .setText("name", name)

+                    .uniqueResult();

+            if (nameCounter != null) {

+                int updatedRows = session.createQuery(hqlUpdateCounter)

+                        .setText("name", nameCounter.getName())

+                        .setInteger("prevCounter", nameCounter.getCounter())

+                        .setInteger("newCounter", nameCounter.getCounter() + 1)

+                        .executeUpdate();

+                if (updatedRows == 1) {

+                    return nameCounter.getCounter() + 1;

+                }

+            } else {

+                Object nameAsId = session.save(new NameCounter(name));

+                //if save success

+                if (nameAsId != null) {

+                    return 1;

+                }

+            }

+            //in case of failure return null, in order to continue the loop

+            return null;

+        });

+        return counter;

+    }

+

+    @Override

+    public int getMaxRetriesGettingFreeNameFromAai() {

+        return maxRetriesGettingFreeNameFromAai;

+    }

+

+    @Override

+    public void setMaxRetriesGettingFreeNameFromAai(int maxRetriesGettingFreeNameFromAai) {

+        this.maxRetriesGettingFreeNameFromAai = maxRetriesGettingFreeNameFromAai;

+    }

+

+    @Override

+    public String getUniqueName(String name, ResourceType resourceType) {

+        //check that name aai response well before increasing counter from DB

+        //Prevents unnecessary increasing of the counter while AAI doesn't response

+        isNameFreeInAai(NAME_FOR_CHECK_AAI_STATUS, resourceType);

+

+        for (int i=0; i<getMaxRetriesGettingFreeNameFromAai(); i++) {

+            int counter = getCounterForName(name);

+            String newName = formatNameAndCounter(name, counter);

+            if (isNameFreeInAai(newName, resourceType)) {

+                return newName;

+            }

+        }

+

+        throw new MaxRetriesException("find unused name for "+name, getMaxRetriesGettingFreeNameFromAai());

+    }

+

+    //the method is protected so we can call it in the UT

+    protected String formatNameAndCounter(String name, int counter) {

+        return name + "_" + String.format("%03d", counter);

+    }

+

+    private boolean isNameFreeInAai(String name, ResourceType resourceType) throws InvalidAAIResponseException {

+        AaiResponse<AaiNodeQueryResponse> aaiResponse = aaiClient.searchNodeTypeByName(name, resourceType);

+        if (aaiResponse.getHttpCode() > 399 || aaiResponse.getT() == null) {

+            throw new InvalidAAIResponseException(aaiResponse);

+        }

+        return CollectionUtils.isEmpty(aaiResponse.getT().resultData);

+    }

+*/

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/DummyAsyncRequest.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/DummyAsyncRequest.java
new file mode 100644
index 0000000..22ce508
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/DummyAsyncRequest.java
@@ -0,0 +1,40 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import com.fasterxml.jackson.annotation.JsonProperty;

+import lombok.AllArgsConstructor;

+import lombok.Getter;

+import lombok.NoArgsConstructor;

+import lombok.Setter;

+import org.onap.osam.job.IJobFactory;

+

+/**

+ * Currently - dummy class for demo purposes

+ */

+@Getter

+@Setter

+@NoArgsConstructor

+@AllArgsConstructor

+public class DummyAsyncRequest implements IJobFactory.AsyncJobRequest {

+

+    @JsonProperty("dummyString")

+    private String dummyString;

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobData.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobData.java
new file mode 100644
index 0000000..4e9ceff
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobData.java
@@ -0,0 +1,73 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import org.onap.osam.job.JobType;

+

+import java.util.Map;

+import java.util.Objects;

+import java.util.TreeMap;

+

+public class JobData {

+

+    private TreeMap<JobType, Map<String, Object>> commandData;

+    private JobSharedData sharedData;

+

+    public JobData() {

+        commandData = new TreeMap<>();

+        sharedData = new JobSharedData();

+    }

+

+    public JobData(TreeMap<JobType, Map<String, Object>> commandData, JobSharedData sharedData) {

+        this.commandData = commandData;

+        this.sharedData = sharedData;

+    }

+

+    public TreeMap<JobType, Map<String, Object>> getCommandData() {

+        return commandData;

+    }

+

+    public void setCommandData(TreeMap<JobType, Map<String, Object>> commandData) {

+        this.commandData = commandData;

+    }

+

+    public JobSharedData getSharedData() {

+        return sharedData;

+    }

+

+    public void setSharedData(JobSharedData sharedData) {

+        this.sharedData = sharedData;

+    }

+

+    @Override

+    public boolean equals(Object o) {

+        if (this == o) return true;

+        if (!(o instanceof JobData)) return false;

+        JobData jobData = (JobData) o;

+        return Objects.equals(getCommandData(), jobData.getCommandData()) &&

+                Objects.equals(getSharedData(), jobData.getSharedData());

+    }

+

+    @Override

+    public int hashCode() {

+

+        return Objects.hash(getCommandData(), getSharedData());

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobFactory.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobFactory.java
new file mode 100644
index 0000000..a8ab0ce
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobFactory.java
@@ -0,0 +1,57 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobFactory;

+import org.onap.osam.job.JobType;

+import org.springframework.stereotype.Component;

+

+import java.util.Map;

+import java.util.UUID;

+

+@Component

+public class JobFactory implements IJobFactory {

+

+    @Override

+    public OsamJob createRootJob(JobType jobType, AsyncJobRequest request, String userId, Integer indexInBulk, Map<String, Object> jobData){

+        OsamJob job = new OsamJob();

+        job.setStatus(JobStatus.PENDING);

+        job.setUuid(UUID.randomUUID());

+        job.setUserId(userId);

+        job.setTypeAndData(jobType, jobData);

+        job.setSharedData(new JobSharedData(job.getUuid(), userId, request));

+        job.setIndexInBulk(indexInBulk);

+        return job;

+    }

+

+    @Override

+    public OsamJob createChildJob(JobType jobType, JobStatus jobStatus, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData) {

+        OsamJob job = new OsamJob();

+        job.setStatus(jobStatus);

+        job.setUuid(UUID.randomUUID());

+        job.setUserId(parentSharedData.getUserId());

+        job.setTypeAndData(jobType, jobData);

+        job.setSharedData(new JobSharedData(job.getUuid(), request, parentSharedData));

+        return job;

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobSchedulerInitializer.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobSchedulerInitializer.java
new file mode 100644
index 0000000..526b823
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobSchedulerInitializer.java
@@ -0,0 +1,94 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import com.google.common.collect.ImmutableMap;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.exception.GenericUncheckedException;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.IJobsDataAccessService;

+import org.onap.osam.job.command.JobCommandFactory;

+import org.quartz.JobBuilder;

+import org.quartz.JobDataMap;

+import org.quartz.JobDetail;

+import org.quartz.Scheduler;

+import org.quartz.SchedulerException;

+import org.quartz.SimpleTrigger;

+import org.quartz.TriggerBuilder;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.scheduling.quartz.SchedulerFactoryBean;

+import org.springframework.stereotype.Component;

+

+import javax.annotation.PostConstruct;

+

+import static org.quartz.SimpleScheduleBuilder.simpleSchedule;

+

+@Slf4j

+@Component

+public class JobSchedulerInitializer {

+

+    private IJobsDataAccessService jobsDataAccessService;

+    private SchedulerFactoryBean schedulerFactoryBean;

+    private JobCommandFactory jobCommandFactory;

+

+    @Autowired

+    public JobSchedulerInitializer(

+            IJobsDataAccessService jobsDataAccessService,

+            SchedulerFactoryBean schedulerFactoryBean,

+            JobCommandFactory JobCommandFactory

+    ) {

+        this.jobsDataAccessService = jobsDataAccessService;

+        this.schedulerFactoryBean = schedulerFactoryBean;

+        this.jobCommandFactory = JobCommandFactory;

+

+    }

+

+    @PostConstruct

+    public void init() {

+        scheduleJobWorker(JobStatus.PENDING, 1);

+        scheduleJobWorker(JobStatus.CREATING, 1);

+        scheduleJobWorker(JobStatus.IN_PROGRESS, 1);

+        scheduleJobWorker(JobStatus.RESOURCE_IN_PROGRESS, 1);

+    }

+

+    private void scheduleJobWorker(JobStatus topic, int intervalInSeconds) {

+        final Scheduler scheduler = schedulerFactoryBean.getScheduler();

+        JobDetail jobDetail = JobBuilder.newJob().ofType(JobWorker.class)

+                .withIdentity("AsyncWorkersJob" + topic)

+                .withDescription("Job that run async worker for " + topic)

+                .setJobData(new JobDataMap(ImmutableMap.of(

+                        "jobsDataAccessService", jobsDataAccessService,

+                        "jobCommandFactory", jobCommandFactory,

+                        "topic", topic

+                )))

+                .build();

+        SimpleTrigger asyncWorkerTrigger = TriggerBuilder.newTrigger().forJob(jobDetail)

+                .withIdentity("AsyncWorkersTrigger" + topic)

+                .withDescription("Trigger to run async worker for " + topic)

+                .withSchedule(simpleSchedule().repeatForever().withIntervalInSeconds(intervalInSeconds))

+                .build();

+        try {

+            scheduler.scheduleJob(jobDetail, asyncWorkerTrigger);

+        } catch (SchedulerException e) {

+            log.error("Failed to schedule trigger for async worker jobs: {}", e.getMessage());

+            throw new GenericUncheckedException(e);

+        }

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobSharedData.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobSharedData.java
new file mode 100644
index 0000000..2c16c95
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobSharedData.java
@@ -0,0 +1,103 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import com.fasterxml.jackson.annotation.JsonTypeInfo;

+import org.onap.osam.job.IJobFactory;

+

+import java.util.Objects;

+import java.util.UUID;

+

+public class JobSharedData {

+

+    protected UUID jobUuid;

+    protected String userId;

+    protected Class requestType;

+    protected UUID rootJobId;

+

+    @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, property="class")

+    protected IJobFactory.AsyncJobRequest request;

+

+    public JobSharedData() {

+    }

+

+    public JobSharedData(UUID jobUuid, String userId, IJobFactory.AsyncJobRequest request) {

+        this.jobUuid = jobUuid;

+        this.userId = userId;

+        this.requestType = request.getClass();

+        this.request = request;

+        this.rootJobId = jobUuid;

+    }

+

+    public JobSharedData(UUID jobUuid, IJobFactory.AsyncJobRequest request, JobSharedData parentData) {

+        this(jobUuid, parentData.getUserId(), request);

+        rootJobId = parentData.getRootJobId() != null ? parentData.getRootJobId() : parentData.getJobUuid();

+    }

+

+

+    public UUID getJobUuid() {

+        return jobUuid;

+    }

+

+    public String getUserId() {

+        return userId;

+    }

+

+    public void setUserId(String userId) {

+        this.userId = userId;

+    }

+

+    public Class getRequestType() {

+        return requestType;

+    }

+

+    public void setRequestType(Class requestType) {

+        this.requestType = requestType;

+    }

+

+    public IJobFactory.AsyncJobRequest getRequest() {

+        return request;

+    }

+

+    public void setRequest(IJobFactory.AsyncJobRequest request) {

+        this.request = request;

+    }

+

+    public UUID getRootJobId() {

+        return rootJobId;

+    }

+

+    @Override

+    public boolean equals(Object o) {

+        if (this == o) return true;

+        if (!(o instanceof JobSharedData)) return false;

+        JobSharedData that = (JobSharedData) o;

+        return Objects.equals(getJobUuid(), that.getJobUuid()) &&

+                Objects.equals(getUserId(), that.getUserId()) &&

+                Objects.equals(getRequestType(), that.getRequestType()) &&

+                Objects.equals(getRootJobId(), that.getRootJobId()) &&

+                Objects.equals(getRequest(), that.getRequest());

+    }

+

+    @Override

+    public int hashCode() {

+        return Objects.hash(getJobUuid(), getUserId(), getRequestType(), getRootJobId(), getRequest());

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobWorker.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobWorker.java
new file mode 100644
index 0000000..97d52a5
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobWorker.java
@@ -0,0 +1,162 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import lombok.extern.slf4j.Slf4j;

+import org.apache.commons.lang3.exception.ExceptionUtils;

+import org.onap.osam.job.exceptions.JobException;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.IJobsDataAccessService;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.command.JobCommandFactory;

+import org.quartz.JobExecutionContext;

+import org.springframework.scheduling.quartz.QuartzJobBean;

+import org.springframework.stereotype.Component;

+

+import java.util.Optional;

+import java.util.UUID;

+

+

+@Slf4j

+@Component

+public class JobWorker extends QuartzJobBean {

+

+    private IJobsDataAccessService jobsDataAccessService;

+    private JobCommandFactory jobCommandFactory;

+    private JobStatus topic;

+

+    @Override

+    protected void executeInternal(JobExecutionContext context) {

+        Optional<OsamJob> job;

+

+        job = pullJob();

+

+        while (job.isPresent()) {

+            OsamJob nextStateOfJob = executeJobAndGetNext(job.get());

+            pushBack(nextStateOfJob);

+            job = pullJob();

+        }

+    }

+

+    private Optional<OsamJob> pullJob() {

+        try {

+            return jobsDataAccessService.pull(topic, UUID.randomUUID().toString());

+        } catch (Exception e) {

+            log.error("failed to pull job from queue, breaking: {}", e, e);

+            tryMutingJobFromException(e);

+

+            return Optional.empty();

+        }

+    }

+

+    private void pushBack(OsamJob nextJob) {

+        try {

+            jobsDataAccessService.pushBack(nextJob);

+        } catch (Exception e) {

+            log.error("failed pushing back job to queue: {}", e, e);

+        }

+    }

+

+    protected OsamJob executeJobAndGetNext(OsamJob job) {

+        //TODO Pavel find out about teplateId

+        log.debug("going to execute job {}: {}/{}",

+                //log.debug("going to execute job {} of {}: {}/{}",

+                String.valueOf(job.getUuid()).substring(0,8),

+                //String.valueOf(job.getTemplateId()).substring(0, 8),

+                job.getStatus(), job.getType());

+

+        NextCommand nextCommand = executeCommandAndGetNext(job);

+

+        return setNextCommandInJob(nextCommand, job);

+    }

+

+    private NextCommand executeCommandAndGetNext(OsamJob job) {

+        NextCommand nextCommand;

+        try {

+            final IJobCommand jobCommand = jobCommandFactory.toCommand(job);

+            nextCommand = jobCommand.call();

+        } catch (Exception e) {

+            log.error("error while executing job from queue: {}", e);

+            nextCommand = new NextCommand(JobStatus.FAILED);

+        }

+

+        if (nextCommand == null) {

+            nextCommand = new NextCommand(JobStatus.STOPPED);

+        }

+        return nextCommand;

+    }

+

+    private OsamJob setNextCommandInJob(NextCommand nextCommand, OsamJob job) {

+        log.debug("transforming job {}: {}/{} -> {}{}",

+                String.valueOf(job.getUuid()).substring(0, 8),

+                job.getStatus(), job.getType(),

+                nextCommand.getStatus(),

+                nextCommand.getCommand() != null ? ("/" + nextCommand.getCommand().getType()) : "");

+

+        job.setStatus(nextCommand.getStatus());

+

+        if (nextCommand.getCommand() != null) {

+            job.setTypeAndData(nextCommand.getCommand().getType(), nextCommand.getCommand().getData());

+        }

+

+        return job;

+    }

+

+

+    private void tryMutingJobFromException(Exception e) {

+        // If there's JobException in the stack, read job uuid from

+        // the exception, and mute it in DB.

+        final int indexOfJobException =

+                ExceptionUtils.indexOfThrowable(e, JobException.class);

+

+        if (indexOfJobException >= 0) {

+            try {

+                final JobException jobException = (JobException) ExceptionUtils.getThrowableList(e).get(indexOfJobException);

+                log.info("muting job: {} ({})", jobException.getJobUuid(), jobException.toString());

+                final boolean success = jobsDataAccessService.mute(jobException.getJobUuid());

+                if (!success) {

+                    log.error("failed to mute job {}", jobException.getJobUuid());

+                }

+            } catch (Exception e1) {

+                log.error("failed to mute job: {}", e1, e1);

+            }

+        }

+    }

+

+    //used by quartz to inject IJobsDataAccessService into the job

+    //see JobSchedulerInitializer

+    public void setJobsDataAccessService(IJobsDataAccessService jobsDataAccessService) {

+        this.jobsDataAccessService = jobsDataAccessService;

+    }

+

+    /*public void setFeatureManager(FeatureManager featureManager) {

+        this.featureManager = featureManager;

+    }*/

+

+    public void setJobCommandFactory(JobCommandFactory jobCommandFactory) {

+        this.jobCommandFactory = jobCommandFactory;

+    }

+

+    public void setTopic(JobStatus topic) {

+        this.topic = topic;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobsDataAccessService.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobsDataAccessService.java
new file mode 100644
index 0000000..18ae378
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/impl/JobsDataAccessService.java
@@ -0,0 +1,211 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import com.google.common.collect.Lists;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.exception.GenericUncheckedException;

+import org.onap.osam.common.exception.InvalidOperationException;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobsDataAccessService;

+import org.onap.osam.job.repository.job.OsamJobRepository;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.beans.factory.annotation.Value;

+import org.springframework.stereotype.Service;

+import org.springframework.util.StringUtils;

+

+import javax.annotation.PostConstruct;

+import java.nio.ByteBuffer;

+import java.sql.Timestamp;

+import java.time.LocalDateTime;

+import java.util.Collection;

+import java.util.Date;

+import java.util.Optional;

+import java.util.UUID;

+

+@Slf4j

+@Service

+public class JobsDataAccessService implements IJobsDataAccessService {

+

+    private OsamJobRepository osamJobRepository;

+    private Long maxOpenedRequestsToAbstractOlt;

+    private int pollingIntervalSeconds;

+

+    @Autowired

+    public JobsDataAccessService(OsamJobRepository osamJobRepository,

+                                 @Value("0") Long maxOpenedRequestsToAbstractOlt,

+                                 @Value("10") int pollingIntervalSeconds) {

+        // tha @Value will inject conservative defaults; overridden in @PostConstruct from configuration

+        this.osamJobRepository = osamJobRepository;

+        this.maxOpenedRequestsToAbstractOlt = maxOpenedRequestsToAbstractOlt;

+        this.pollingIntervalSeconds = pollingIntervalSeconds;

+    }

+

+    @PostConstruct

+    public void configure() {

+        //TODO define defaults

+        /*maxOpenedRequestsToAbstractOlt = Integer.parseInt(System.getProperty(VidProperties.MSO_MAX_OPENED_INSTANTIATION_REQUESTS));

+        pollingIntervalSeconds = Integer.parseInt(System.getProperty(VidProperties.MSO_ASYNC_POLLING_INTERVAL_SECONDS));*/

+    }

+

+    public void deleteAll() {

+        osamJobRepository.deleteAll();

+    }

+

+    @Override

+    public UUID add(OsamJob job) {

+        osamJobRepository.save(job);

+        return job.getUuid();

+    }

+

+    @Override

+    public Optional<OsamJob> pull(JobStatus topic, String ownerId) {

+        OsamJob osamJob;

+        int updatedEntities;

+        do {

+

+            Optional<OsamJob> optionalOsamJob = selectQueryByJobStatus(topic);

+            if (!optionalOsamJob.isPresent()) {

+                return optionalOsamJob;

+            }

+

+            osamJob = optionalOsamJob.get();

+            final UUID uuid = osamJob.getUuid();

+            final Integer age = osamJob.getAge();

+

+            osamJob.setTakenBy(ownerId);

+

+            // It might become that a job was taken and pushed-back already, before we

+            // arrived here, so we're verifying the age was not pushed forward.

+            // Age is actually forwarded upon pushBack().

+            updatedEntities = osamJobRepository.updateOsamCoreJobsAge(ownerId, uuid, age);

+

+        } while (updatedEntities == 0);

+

+        return Optional.ofNullable(osamJob);

+    }

+

+    private java.sql.Timestamp nowMinusInterval() {

+        return Timestamp.valueOf(LocalDateTime.now().minusSeconds(pollingIntervalSeconds));

+    }

+

+    private Optional<OsamJob> selectQueryByJobStatus(JobStatus topic){

+        //TODO Pavel understand this interval

+        //String intervalCondition = (topic==JobStatus.CREATING) ? "" : (" and MODIFIED_DATE <= '" + nowMinusInterval()+"'");

+        return osamJobRepository.queryFirst1ByStatusAndTakenByIsNullAndDeletedAtIsNullOrderByModifiedDateAsc(topic).stream().findFirst();

+

+    }

+

+    private Optional<OsamJob> sqlQueryForTopic(JobStatus topic) {

+        switch (topic) {

+            case IN_PROGRESS:

+            case RESOURCE_IN_PROGRESS:

+            case CREATING:

+            case PENDING:

+                return selectQueryByJobStatus(topic);

+            //TODO Pavel - at first stage, using the naive query for pending topic

+            /*case PENDING:

+                return osamJobRepository.findOsamJobsPending(maxOpenedRequestsToAbstractOlt);*/

+            default:

+                throw new GenericUncheckedException("Unsupported topic to pull from: " + topic);

+        }

+    }

+

+

+    private byte[] getUuidAsByteArray(UUID owner) {

+        ByteBuffer bb = ByteBuffer.wrap(new byte[16]);

+        bb.putLong(owner.getMostSignificantBits());

+        bb.putLong(owner.getLeastSignificantBits());

+        return bb.array();

+    }

+

+    @Override

+    public void pushBack(OsamJob job) {

+        final Optional<OsamJob> remoteDaoJob = osamJobRepository.findByUuid(job.getUuid());

+

+        if (!remoteDaoJob.isPresent()) {

+            throw new IllegalStateException("Can push back only pulled jobs. Add new jobs using add()");

+        }

+

+        if (remoteDaoJob.get().getTakenBy() == null) {

+            throw new IllegalStateException("Can push back only pulled jobs. This one already pushed back.");

+        }

+

+        job.setTakenBy(null);

+

+        Integer age = job.getAge();

+        job.setAge(age + 1);

+

+        log.debug("{}/{}", job.getStatus(), job.getType());

+

+        osamJobRepository.save(job);

+    }

+

+    /*private OsamJob castToOsamJob(OsamJob job) {

+        if (!(job instanceof OsamJob)) {

+            throw new UnsupportedOperationException("Can't add " + job.getClass() + " to " + this.getClass());

+        }

+        return (OsamJob) job;

+    }*/

+

+    @Override

+    public Collection<OsamJob> peek() {

+        return Lists.newArrayList(osamJobRepository.findAll());

+    }

+

+    @Override

+    public OsamJob peek(UUID jobId) {

+        return osamJobRepository.findByUuid(jobId).orElse(null);

+    }

+

+    @Override

+    public void delete(UUID jobId) {

+        Date now = new Date();

+        Integer updatedEntities = osamJobRepository.updateOsamCoreJobToBeDeleted(now, jobId, JobStatus.PENDING.toString(), JobStatus.STOPPED.toString());

+

+        if (updatedEntities == 0) {

+            final Optional<OsamJob> remoteDaoJob = osamJobRepository.findByUuid(jobId);

+

+            if (!remoteDaoJob.isPresent() || remoteDaoJob.get().getUuid() == null) {

+                log.debug("jobId {}: Service does not exist", jobId);

+                throw new InvalidOperationException("Service does not exist");

+            }

+

+            if (!remoteDaoJob.get().equals(JobStatus.PENDING) && !remoteDaoJob.get().getStatus().equals(JobStatus.STOPPED) || !StringUtils.isEmpty(remoteDaoJob.get().getTakenBy())) {

+                log.debug("jobId {}: Service status does not allow deletion from the queue, status = {}", jobId, remoteDaoJob.get().getStatus() +

+                ", takenBy " + remoteDaoJob.get().getTakenBy());

+                throw new InvalidOperationException("Service status does not allow deletion from the queue");

+            }

+

+            throw new InvalidOperationException("Service deletion failed");

+        }

+    }

+

+    @Override

+    public boolean mute(UUID jobId) {

+        if (jobId == null) {

+            return false;

+        }

+        final String prefix = "DUMP";

+        Integer updatedEntities = osamJobRepository.muteOsamCoreJob(jobId, prefix);

+        return updatedEntities != 0;

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/repository/job/OsamJobRepository.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/repository/job/OsamJobRepository.java
new file mode 100644
index 0000000..f473c5d
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/repository/job/OsamJobRepository.java
@@ -0,0 +1,66 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.repository.job;

+

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.springframework.data.jpa.repository.Modifying;

+import org.springframework.data.jpa.repository.Query;

+import org.springframework.data.repository.CrudRepository;

+import org.springframework.data.repository.query.Param;

+import org.springframework.transaction.annotation.Transactional;

+

+import java.util.Date;

+import java.util.List;

+import java.util.Optional;

+import java.util.UUID;

+

+public interface OsamJobRepository extends CrudRepository<OsamJob, Long> {

+

+

+

+    Optional<OsamJob> findByUuid(UUID uuid);

+

+    List<OsamJob> findAllByUuid(Iterable<UUID> uuids);

+

+    //TODO Pavel add intervalCondition to the query

+    //String intervalCondition = (topic==JobStatus.CREATING) ? "" : (" and MODIFIED_DATE <= '" + nowMinusInterval()+"'");

+    //@Query("select o from OsamJob o where o.status = :status and o.takenBy is null and o.deletedAt is null order by o.modifiedDate asc")

+    //List<OsamJob> queryFirst1ByStatusAndTakenByIsNullAndDeleteAtIsNullOrderByModifiedDateAsc(@Param("status") JobStatus status);

+    List<OsamJob> queryFirst1ByStatusAndTakenByIsNullAndDeletedAtIsNullOrderByModifiedDateAsc(@Param("status") JobStatus status);

+

+    //Updates

+

+    @Transactional

+    @Modifying

+    @Query("update OsamJob job set job.takenBy = :takenBy where job.uuid = :uuid and job.age = :age and job.takenBy is null")

+    Integer updateOsamCoreJobsAge(@Param("takenBy") String takenBy, @Param("uuid") UUID uuid, @Param("age") Integer age);

+

+    @Transactional

+    @Modifying

+    @Query("update OsamJob job set job.deletedAt = :now where job.uuid = :uuid and job.status in(:pending, :stopped) and job.takenBy is null")

+    Integer updateOsamCoreJobToBeDeleted(@Param("now") Date date, @Param("uuid") UUID uuid, @Param("pending") String pending, @Param("stopped") String stopped);

+

+    @Transactional

+    @Modifying

+    @Query("update OsamJob job set job.status = concat(':prefix_',job.status), job.takenBy = null where job.uuid = :uuid and job.status not like ':prefix_%'")

+    Integer muteOsamCoreJob(@Param("uuid") UUID uuid, @Param("")String prefix);

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/utils/Streams.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/utils/Streams.java
new file mode 100644
index 0000000..35ffb98
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/utils/Streams.java
@@ -0,0 +1,66 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.utils;

+

+import java.util.Iterator;

+import java.util.Spliterator;

+import java.util.Spliterators;

+import java.util.function.Consumer;

+import java.util.function.Predicate;

+import java.util.stream.Stream;

+import java.util.stream.StreamSupport;

+

+public class Streams {

+    public static <R> Predicate<R> not(Predicate<R> predicate) {

+        return predicate.negate();

+    }

+

+    public static <T> Stream<T> fromIterator(final Iterator<T> iterator) {

+        Iterable<T> iterable = () -> iterator;

+        return StreamSupport.<T>stream(iterable.spliterator(), false);

+    }

+

+

+    // https://stackoverflow.com/questions/20746429/limit-a-stream-by-a-predicate

+    private static <T> Spliterator<T> takeWhile(

+            Spliterator<T> splitr, Predicate<? super T> predicate) {

+        return new Spliterators.AbstractSpliterator<T>(splitr.estimateSize(), 0) {

+            boolean stillGoing = true;

+            @Override public boolean tryAdvance(Consumer<? super T> consumer) {

+                if (stillGoing) {

+                    boolean hadNext = splitr.tryAdvance(elem -> {

+                        if (predicate.test(elem)) {

+                            consumer.accept(elem);

+                        } else {

+                            stillGoing = false;

+                        }

+                    });

+                    return hadNext && stillGoing;

+                }

+                return false;

+            }

+        };

+    }

+

+    public static <T> Stream<T> takeWhile(Stream<T> stream, Predicate<? super T> predicate) {

+        return StreamSupport.stream(takeWhile(stream.spliterator(), predicate), false);

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/utils/TimeUtils.java b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/utils/TimeUtils.java
new file mode 100644
index 0000000..bbd7ec3
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/main/java/org/onap/osam/job/utils/TimeUtils.java
@@ -0,0 +1,40 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.utils;

+

+import java.time.ZonedDateTime;

+import java.time.format.DateTimeFormatter;

+

+public class TimeUtils {

+    private static DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME;

+

+    private TimeUtils() {

+        // explicit private constructor, to hide the implicit public constructor

+    }

+

+    public static ZonedDateTime parseZonedDateTime(String time) {

+

+        return ZonedDateTime.from(formatter.parse(time));

+    }

+

+    public static String zonedDateTimeToString(ZonedDateTime time) {

+        return formatter.format(time);

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/command/JobCommandFactoryTest.java b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/command/JobCommandFactoryTest.java
new file mode 100644
index 0000000..0ea9933
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/command/JobCommandFactoryTest.java
@@ -0,0 +1,122 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import com.fasterxml.jackson.annotation.JsonCreator;

+import com.fasterxml.jackson.annotation.JsonProperty;

+import com.google.common.collect.ImmutableMap;

+import org.mockito.Mock;

+import org.mockito.MockitoAnnotations;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobFactory;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.JobType;

+import org.onap.osam.job.command.JobCommandFactory;

+import org.onap.osam.job.impl.JobSharedData;

+import org.testng.annotations.BeforeMethod;

+import org.testng.annotations.DataProvider;

+import org.testng.annotations.Test;

+

+import java.util.Arrays;

+import java.util.Map;

+import java.util.Objects;

+import java.util.UUID;

+import java.util.stream.Collectors;

+

+import static org.hamcrest.CoreMatchers.equalTo;

+import static org.hamcrest.MatcherAssert.assertThat;

+import static org.mockito.Mockito.verify;

+import static org.mockito.Mockito.when;

+

+public class JobCommandFactoryTest {

+

+    private JobCommandFactory jobCommandFactory;

+

+    @Mock

+    private OsamJob job;

+

+    @Mock

+    private IJobCommand mockCommand;

+

+    @BeforeMethod

+    public void initMocks() {

+        MockitoAnnotations.initMocks(this);

+    }

+

+    @BeforeMethod

+    public void setUp() {

+        jobCommandFactory = new JobCommandFactory(any -> mockCommand);

+    }

+

+    @DataProvider

+    public Object[][] jobTypes() {

+        return Arrays.stream(

+                JobType.values()

+        ).map(v -> new Object[]{v}).collect(Collectors.toList()).toArray(new Object[][]{});

+

+    }

+

+    public static class MockedRequest implements IJobFactory.AsyncJobRequest {

+

+        final public int x;

+        final public String y;

+

+        @JsonCreator

+        public MockedRequest(@JsonProperty("x")int x, @JsonProperty("y")String y) {

+            this.x = x;

+            this.y = y;

+        }

+

+        @Override

+        public boolean equals(Object o) {

+            if (this == o) return true;

+            if (!(o instanceof MockedRequest)) return false;

+            MockedRequest that = (MockedRequest) o;

+            return x == that.x &&

+                    Objects.equals(y, that.y);

+        }

+

+        @Override

+        public int hashCode() {

+

+            return Objects.hash(x, y);

+        }

+    }

+

+    @Test(dataProvider = "jobTypes")

+    public void givenJob_createCommandCallsTheInitAndReturnsTheInstance(JobType jobType) {

+

+        final UUID uuid = UUID.randomUUID();

+        final Map<String, Object> data = ImmutableMap.of("foo", "bar");

+        final JobSharedData sharedData = new JobSharedData(uuid, "userid", new MockedRequest(1,"a"));

+

+        when(job.getType()).thenReturn(jobType);

+        when(job.getUuid()).thenReturn(uuid);

+        when(job.getDataMap()).thenReturn(data);

+        when(job.getSharedData()).thenReturn(sharedData);

+

+        final IJobCommand command = jobCommandFactory.toCommand(job);

+

+        verify(mockCommand).init(sharedData, data);

+

+        assertThat(command, equalTo(mockCommand));

+    }

+

+}

diff --git a/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/command/WatchingCommandTest.java b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/command/WatchingCommandTest.java
new file mode 100644
index 0000000..0e595a6
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/command/WatchingCommandTest.java
@@ -0,0 +1,105 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.command;

+

+import org.mockito.InjectMocks;

+import org.mockito.Mock;

+import org.mockito.MockitoAnnotations;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobFactory;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.AsyncJobService;

+import org.onap.osam.job.command.WatchingCommand;

+import org.onap.osam.job.impl.JobSharedData;

+import org.onap.osam.job.repository.job.OsamJobRepository;

+import org.testng.annotations.BeforeMethod;

+import org.testng.annotations.DataProvider;

+import org.testng.annotations.Test;

+

+import java.util.ArrayList;

+import java.util.Arrays;

+import java.util.List;

+import java.util.UUID;

+import java.util.stream.Collectors;

+

+import static org.hamcrest.MatcherAssert.assertThat;

+import static org.hamcrest.core.Is.is;

+import static org.mockito.Matchers.any;

+import static org.mockito.Matchers.eq;

+import static org.mockito.Mockito.*;

+

+public class WatchingCommandTest {

+

+    @Mock

+    private AsyncJobService asyncInstantiationBL;

+

+    @Mock

+    private OsamJobRepository osamJobRepository;

+

+    @InjectMocks

+    private WatchingCommand watchingCommand = new WatchingCommand();

+

+    @DataProvider

+    public static Object[][] expectedJobStatusDataProvider() {

+        return new Object[][]{

+                {Arrays.asList(JobStatus.COMPLETED, JobStatus.COMPLETED), JobStatus.COMPLETED, true},

+                {Arrays.asList(JobStatus.FAILED, JobStatus.COMPLETED), JobStatus.COMPLETED_WITH_ERRORS, true},

+                {Arrays.asList(JobStatus.STOPPED, JobStatus.COMPLETED), JobStatus.COMPLETED_WITH_ERRORS, false},

+                {Arrays.asList(JobStatus.IN_PROGRESS, JobStatus.FAILED), JobStatus.IN_PROGRESS, true},

+                {Arrays.asList(JobStatus.IN_PROGRESS, JobStatus.COMPLETED), JobStatus.IN_PROGRESS, true},

+                {Arrays.asList(JobStatus.IN_PROGRESS, JobStatus.IN_PROGRESS), JobStatus.IN_PROGRESS, true},

+                {Arrays.asList(null, JobStatus.COMPLETED), JobStatus.COMPLETED_WITH_ERRORS, true},

+                {Arrays.asList(null, JobStatus.IN_PROGRESS), JobStatus.IN_PROGRESS, true},

+                {Arrays.asList(null, JobStatus.FAILED), JobStatus.COMPLETED_WITH_ERRORS, false},

+                {new ArrayList<>(), JobStatus.COMPLETED, true}

+        };

+    }

+

+    @BeforeMethod

+    public void initMocks() {

+        MockitoAnnotations.initMocks(this);

+    }

+

+    @Test(dataProvider = "expectedJobStatusDataProvider")

+    public void testAssertNextCommandIsValid(List<JobStatus> childJobs, JobStatus expectedCommandStatus, boolean isService) {

+        //init sql result mock

+        List<OsamJob> mockChildren = childJobs.stream().map(st -> {

+            OsamJob job = new OsamJob();

+            job.setUuid(UUID.randomUUID());

+            job.setStatus(st);

+            return job;

+        }).collect(Collectors.toList());

+        when(osamJobRepository.findAllByUuid(any()))

+                .thenReturn(mockChildren);

+

+        //init job data for watching command

+        UUID jobUUID = UUID.randomUUID();

+        JobSharedData sharedData = new JobSharedData(jobUUID, "mockedUserID", mock(TestRequest.class));

+        List<UUID> uuids = mockChildren.stream().map(job -> job.getUuid()).collect(Collectors.toList());

+        watchingCommand.init(sharedData, uuids, isService);

+

+        //execute command and verify

+        NextCommand nextCommand = watchingCommand.call();

+        assertThat(nextCommand.getStatus(), is(expectedCommandStatus));

+    }

+

+    public static class TestRequest implements IJobFactory.AsyncJobRequest{}

+}

diff --git a/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/impl/JobAdapterTest.java b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/impl/JobAdapterTest.java
new file mode 100644
index 0000000..289cd99
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/impl/JobAdapterTest.java
@@ -0,0 +1,113 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import com.google.common.collect.ImmutableMap;

+import org.apache.commons.lang3.RandomUtils;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobFactory;

+import org.onap.osam.job.JobType;

+import org.onap.osam.job.command.JobCommandFactoryTest;

+import org.testng.annotations.Test;

+

+import java.util.UUID;

+

+import static org.testng.Assert.assertEquals;

+import static org.testng.Assert.assertNotEquals;

+import static org.testng.AssertJUnit.assertNotNull;

+

+public class JobAdapterTest {

+

+    @Test

+    public void testCreateServiceInstantiationJob() {

+        IJobFactory jobAdapter = new JobFactory();

+

+        JobType jobType = JobType.NoOp;

+        IJobFactory.AsyncJobRequest request = new JobCommandFactoryTest.MockedRequest(42,"nothing");

+        String userId = "ou012t";

+        String optimisticUniqueServiceInstanceName = "optimisticUniqueServiceInstanceName";

+        int indexInBulk = RandomUtils.nextInt();

+        OsamJob job = jobAdapter.createRootJob(

+                jobType,

+                request,

+                userId,

+                indexInBulk,

+                ImmutableMap.of());

+

+        assertEquals(job.getType(), jobType);

+        assertEquals(job.getSharedData().getRequest(), request);

+        assertEquals(job.getSharedData().getRequestType(), request.getClass());

+        assertEquals(job.getSharedData().getUserId(), userId);

+        assertEquals(job.getSharedData().getJobUuid(), job.getUuid());

+        assertEquals(job.getSharedData().getRootJobId(), job.getUuid());

+        assertNotNull(job.getUuid());

+        assertEquals((int)job.getIndexInBulk(), indexInBulk );

+        assertEquals(job.getStatus(), JobStatus.PENDING);

+    }

+

+    @Test

+    public void testCreateChildJob() {

+

+        IJobFactory jobAdapter = new JobFactory();

+

+        String userId = "ou012t";

+        String optimisticUniqueServiceInstanceName = "optimisticUniqueServiceInstanceName";

+        int indexInBulk = RandomUtils.nextInt();

+        OsamJob grandJob = jobAdapter.createRootJob(

+                JobType.HttpCall,

+                new JobCommandFactoryTest.MockedRequest(99, "anything"),

+                userId,

+                indexInBulk,

+                ImmutableMap.of()

+        );

+

+        JobStatus jobStatus = JobStatus.PAUSE;

+        JobType jobType = JobType.NoOp;

+        IJobFactory.AsyncJobRequest request = new JobCommandFactoryTest.MockedRequest(42,"nothing");

+        OsamJob parentJob = jobAdapter.createChildJob(jobType, jobStatus, request, grandJob.getSharedData(), ImmutableMap.of());

+

+        assertEquals(parentJob.getType(), jobType);

+        assertEquals(parentJob.getSharedData().getRequest(), request);

+        assertEquals(parentJob.getSharedData().getRequestType(), request.getClass());

+        assertEquals(parentJob.getSharedData().getUserId(), userId);

+        assertEquals(parentJob.getSharedData().getJobUuid(), parentJob.getUuid());

+        assertNotNull(parentJob.getUuid());

+        assertNotEquals(parentJob.getUuid(), grandJob.getUuid());

+        assertEquals(parentJob.getStatus(), jobStatus);

+        assertEquals(parentJob.getSharedData().getRootJobId(), grandJob.getUuid());

+

+        JobStatus jobStatus2 = JobStatus.IN_PROGRESS;

+        JobType jobType2 = JobType.HttpCall;

+        IJobFactory.AsyncJobRequest request2 = new JobCommandFactoryTest.MockedRequest(66,"abc");

+        OsamJob job = jobAdapter.createChildJob(jobType2, jobStatus2, request2, parentJob.getSharedData(), ImmutableMap.of());

+

+        assertEquals(job.getType(), jobType2);

+        assertEquals(job.getSharedData().getRequest(), request2);

+        assertEquals(job.getSharedData().getRequestType(), request2.getClass());

+        assertEquals(job.getSharedData().getUserId(), userId);

+        assertEquals(job.getSharedData().getJobUuid(), job.getUuid());

+        assertNotNull(job.getUuid());

+        assertNotEquals(job.getUuid(), parentJob.getUuid());

+        assertEquals(job.getStatus(), jobStatus2);

+        assertEquals(job.getSharedData().getRootJobId(), grandJob.getUuid());

+

+    }

+}

diff --git a/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/impl/JobWorkerTest.java b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/impl/JobWorkerTest.java
new file mode 100644
index 0000000..f38c238
--- /dev/null
+++ b/osam-core-framework/async-jobs/src/test/java/org/onap/osam/job/impl/JobWorkerTest.java
@@ -0,0 +1,129 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.job.impl;

+

+import com.google.common.collect.ImmutableMap;

+import org.apache.commons.lang3.RandomUtils;

+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

+import org.apache.commons.lang3.builder.ToStringStyle;

+import org.hamcrest.Matcher;

+import org.mockito.InjectMocks;

+import org.mockito.Mock;

+import org.mockito.MockitoAnnotations;

+import org.onap.osam.job.dao.job.JobStatus;

+import org.onap.osam.job.dao.job.OsamJob;

+import org.onap.osam.job.IJobFactory;

+import org.onap.osam.job.IJobCommand;

+import org.onap.osam.job.JobType;

+import org.onap.osam.job.NextCommand;

+import org.onap.osam.job.command.HttpCallCommand;

+import org.onap.osam.job.command.JobCommandFactory;

+import org.onap.osam.job.impl.JobFactory;

+import org.onap.osam.job.impl.JobWorker;

+import org.testng.annotations.BeforeMethod;

+import org.testng.annotations.Test;

+

+import java.util.Map;

+import java.util.UUID;

+

+import static org.hamcrest.MatcherAssert.assertThat;

+import static org.hamcrest.Matchers.*;

+import static org.hamcrest.core.Is.is;

+import static org.mockito.Matchers.any;

+import static org.mockito.Mockito.mock;

+import static org.mockito.Mockito.when;

+

+public class JobWorkerTest {

+

+

+    @Mock

+    private JobCommandFactory jobCommandFactory;

+

+    @InjectMocks

+    private JobWorker jobWorker = new JobWorker();

+

+    private final IJobCommand jobCommand = mock(IJobCommand.class);

+    private OsamJob jobUnderTest;

+    private IJobFactory.AsyncJobRequest originalData;

+    private JobType originalType;

+

+    @BeforeMethod

+    public void initMocks() {

+        MockitoAnnotations.initMocks(this);

+

+        when(jobCommandFactory.toCommand(any())).thenReturn(jobCommand);

+

+        originalData = new IJobFactory.AsyncJobRequest() {

+            public final Map datum = ImmutableMap.of("some", "data");

+            public final String foobar = "aux";

+        };

+

+        originalType = JobType.HttpCall;

+        jobUnderTest = new JobFactory().createRootJob(

+                originalType,

+                originalData,

+                "my user id",

+                RandomUtils.nextInt(),

+                ImmutableMap.of()

+        );

+    }

+

+    @Test

+    public void executeJobAndStepToNext_givenNull_onlyStatusModified() {

+

+        assertNextJobAfterExecuteJob(null, new String[]{"status"}, allOf(

+                hasProperty("status", is(JobStatus.STOPPED)),

+                hasProperty("sharedData", hasProperty("request", is(originalData))),

+                hasProperty("type", is(originalType)))

+        );

+    }

+

+    @Test

+    public void executeJobAndStepToNext_givenNextJob_jobDataIsModified() {

+

+        final JobStatus nextStatus = JobStatus.IN_PROGRESS;

+

+        final UUID jobUuid = UUID.randomUUID();

+        final NextCommand nextCommand = new NextCommand(nextStatus, new HttpCallCommand("my strange url", jobUuid));

+

+        String[] excludedFields = {"status", "data", "type"};

+

+        assertNextJobAfterExecuteJob(nextCommand, excludedFields, allOf(

+                hasProperty("status", is(nextStatus)),

+                hasProperty("dataMap", is(nextCommand.getCommand().getData())),

+                hasProperty("type", is(nextCommand.getCommand().getType())))

+        );

+    }

+

+    private void assertNextJobAfterExecuteJob(NextCommand nextCommand, String[] excludedFields, Matcher<OsamJob> jobMatcher) {

+        when(jobCommand.call()).thenReturn(nextCommand);

+

+        String jobBefore = new ReflectionToStringBuilder(jobUnderTest, ToStringStyle.SHORT_PREFIX_STYLE).setExcludeFieldNames(excludedFields).toString();

+

+        ////// FUNCTION UNDER TEST /////

+        OsamJob nextJob = jobWorker.executeJobAndGetNext(jobUnderTest);

+        ////////////////////////////////

+

+        String jobAfter = new ReflectionToStringBuilder(nextJob, ToStringStyle.SHORT_PREFIX_STYLE).setExcludeFieldNames(excludedFields).toString();

+

+        assertThat(nextJob, jobMatcher);

+        assertThat(jobAfter, equalTo(jobBefore));

+    }

+}

diff --git a/osam-core-framework/common/pom.xml b/osam-core-framework/common/pom.xml
new file mode 100644
index 0000000..f91bf82
--- /dev/null
+++ b/osam-core-framework/common/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>common</artifactId>

+

+    <dependencies>

+        <dependency>

+            <groupId>${project.groupId}</groupId>

+            <artifactId>osam-common</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+    </dependencies>

+

+

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/AbstractOLTException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/AbstractOLTException.java
new file mode 100644
index 0000000..001198a
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/AbstractOLTException.java
@@ -0,0 +1,29 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.common.exception;

+

+public class AbstractOLTException extends GenericUncheckedException {

+    public AbstractOLTException(String message) {

+        super(message);

+    }

+    public AbstractOLTException(String format, Object... arguments) {

+        super(format,arguments);

+    }

+}

diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/BadFormatException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/BadFormatException.java
new file mode 100644
index 0000000..c7ef4df
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/BadFormatException.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.common.exception;

+

+

+/**

+ * Created by cemturker on 19.09.2018.

+ */

+public class BadFormatException extends GenericUncheckedException {

+    public BadFormatException(String message) {

+        super(message);

+    }

+    public BadFormatException(String format, Object... arguments) {

+        super(format,arguments);

+    }

+}

diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/GenericUncheckedException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/GenericUncheckedException.java
new file mode 100644
index 0000000..60183a2
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/GenericUncheckedException.java
@@ -0,0 +1,38 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+package org.onap.osam.common.exception;

+

+public class GenericUncheckedException extends RuntimeException {

+    public GenericUncheckedException(String message) {

+        super(message);

+    }

+

+    public GenericUncheckedException(String message, Throwable cause) {

+        super(message, cause);

+    }

+

+    public GenericUncheckedException(Throwable cause) {

+        super(cause);

+    }

+

+    public GenericUncheckedException(String format, Object... arguments) {

+        super(String.format(format, arguments));

+    }

+}

diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/InvalidOperationException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/InvalidOperationException.java
new file mode 100644
index 0000000..75447a4
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/InvalidOperationException.java
@@ -0,0 +1,35 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.common.exception;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public class InvalidOperationException extends GenericUncheckedException {

+    public InvalidOperationException(String message) {

+        super(message);

+    }

+    public InvalidOperationException(String format, Object... arguments) {

+        super(format,arguments);

+    }

+}

diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/NotFoundException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/NotFoundException.java
new file mode 100644
index 0000000..10be17a
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/NotFoundException.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.common.exception;

+

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public class NotFoundException extends GenericUncheckedException {

+    public NotFoundException(String message) {

+        super(message);

+    }

+    public NotFoundException(String format, Object... arguments) {

+        super(format,arguments);

+    }

+}

diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/ServerException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/ServerException.java
new file mode 100644
index 0000000..07bf68c
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/ServerException.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.common.exception;

+

+

+/**

+ * Created by Zafer Kaban on 07.12.2018.

+ */

+public class ServerException extends GenericUncheckedException {

+    public ServerException(String message) {

+        super(message);

+    }

+    public ServerException(String format, Object... arguments) {

+        super(format,arguments);

+    }

+}

diff --git a/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/UnknownTypeException.java b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/UnknownTypeException.java
new file mode 100644
index 0000000..4781a72
--- /dev/null
+++ b/osam-core-framework/common/src/main/java/org/onap/osam/common/exception/UnknownTypeException.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.common.exception;

+

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public class UnknownTypeException extends GenericUncheckedException {

+    public UnknownTypeException(String message) {

+        super(message);

+    }

+    public UnknownTypeException(String format, Object... arguments) {

+        super(format,arguments);

+    }

+}

diff --git a/osam-core-framework/core/pom.xml b/osam-core-framework/core/pom.xml
new file mode 100644
index 0000000..ba559c1
--- /dev/null
+++ b/osam-core-framework/core/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>core</artifactId>

+    <dependencies>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>external</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>api</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+    </dependencies>

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/AbstractBaseServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/AbstractBaseServiceImpl.java
new file mode 100644
index 0000000..ef69df9
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/AbstractBaseServiceImpl.java
@@ -0,0 +1,72 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.model.dao.BaseEntity;

+import org.slf4j.Logger;

+import org.slf4j.LoggerFactory;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.ArrayList;

+import java.util.Collections;

+import java.util.List;

+import java.util.Optional;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+

+public abstract class AbstractBaseServiceImpl {

+

+    protected Logger log = LoggerFactory.getLogger(this.getClass());

+

+    protected <T extends BaseEntity> T add(T t, CrudRepository<T, Long> repository) {

+        t = repository.save(t);

+        log.info("{} is added",t);

+        return t;

+    }

+

+    protected <T extends BaseEntity> void remove(Long id, CrudRepository<T, Long> repository, Class classz) {

+        repository.deleteById(id);

+        log.info("{} is deleted for {}", id, classz.getName());

+    }

+

+    protected <T extends BaseEntity> T get(Long id, CrudRepository<T, Long> repository) {

+        Optional<T> optional = repository.findById(id);

+        if (!optional.isPresent()) {

+            throw new NotFoundException("id:"+id+" is not found");

+        }

+        return optional.get();

+    }

+

+    protected <T extends BaseEntity> List<T> getAll(CrudRepository<T, Long> repository) {

+        List<T> ts = new ArrayList<>();

+        repository.findAll().iterator().forEachRemaining(ts::add);

+        return Collections.unmodifiableList(ts);

+    }

+

+    protected <T extends BaseEntity> Long count(CrudRepository<T, Long> repository) {

+        return repository.count();

+    }

+}

diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/AccessPodServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/AccessPodServiceImpl.java
new file mode 100644
index 0000000..4113d1b
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/AccessPodServiceImpl.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import org.onap.osam.external.aai.AaiClient;

+import org.onap.osam.external.aai.model.PNF;

+import org.onap.osam.model.dao.AccessPod;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.model.repository.AccessPodRepository;

+import org.onap.osam.api.service.AccessPodService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.stereotype.Service;

+

+import java.util.List;

+import java.util.Optional;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+@Service

+public class AccessPodServiceImpl extends AbstractBaseServiceImpl implements AccessPodService {

+

+    private AccessPodRepository accessPodRepository;

+

+    private AaiClient aaiClient;

+

+    @Autowired

+    public AccessPodServiceImpl(AccessPodRepository accessPodRepository, AaiClient aaiClient) {

+        this.accessPodRepository = accessPodRepository;

+        this.aaiClient = aaiClient;

+    }

+

+

+    @Override

+    public AccessPod addOrUpdate(AccessPod value) {

+        //aai logic is commented out, to allow manual registering of SEBA PODs in OSAM Core

+        //PNF pnf = aaiClient.queryPnf(value.getPnfId());

+        Optional<AccessPod> accessPodOptional = accessPodRepository.findByPnfId(value.getPnfId());

+        if (accessPodOptional.isPresent()) {

+            AccessPod tmp = accessPodOptional.get();

+            value.setId(tmp.getId());

+        }

+        add(value,accessPodRepository);

+        //TODO need to update connection to grpc!!

+        return value;

+    }

+

+    @Override

+    public void removeById(Long key) {

+        remove(key,accessPodRepository,AccessPod.class);

+    }

+

+    @Override

+    public AccessPod getById(Long key) {

+        return get(key,accessPodRepository);

+    }

+

+    @Override

+    public List<AccessPod> getAll() {

+        return getAll(accessPodRepository);

+    }

+

+    @Override

+    public AccessPod findByPnfId(String pnfId) {

+        Optional<AccessPod> accessPodOp = accessPodRepository.findByPnfId(pnfId);

+        if (!accessPodOp.isPresent()) {

+            log.error("Access POD with pnfId : {} is not found", pnfId);

+            throw new NotFoundException("Access POD with pnfId : {} is not found", pnfId);

+        }

+        return accessPodOp.get();

+    }

+

+    @Override

+    public void removeByPnfId(String pnfId) {

+        accessPodRepository.removeByPnfId(pnfId);

+    }

+}

diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/AlarmServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/AlarmServiceImpl.java
new file mode 100644
index 0000000..57aa5f1
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/AlarmServiceImpl.java
@@ -0,0 +1,78 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import org.onap.osam.model.dao.AlarmsAndEvents;

+import org.onap.osam.api.service.AlarmService;

+import org.onap.osam.common.exception.UnknownTypeException;

+import org.onap.osam.model.dao.ActiveAlarmsAndEvents;

+import org.onap.osam.model.dao.HistoricalAlarmsAndEvents;

+import org.onap.osam.model.repository.ActiveAlarmsAndEventsRepository;

+import org.onap.osam.model.repository.HistoricalAlarmsAndEventsRepository;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.stereotype.Service;

+

+import java.util.Date;

+import java.util.List;

+

+@Service

+public class AlarmServiceImpl extends AbstractBaseServiceImpl implements AlarmService {

+

+    ActiveAlarmsAndEventsRepository activeAlarmsAndEventsRepository;

+    HistoricalAlarmsAndEventsRepository historicalAlarmsAndEventsRepository;

+

+    @Autowired

+    public AlarmServiceImpl(ActiveAlarmsAndEventsRepository activeAlarmsAndEventsRepository,

+                            HistoricalAlarmsAndEventsRepository historicalAlarmsAndEventsRepository){

+        this.activeAlarmsAndEventsRepository = activeAlarmsAndEventsRepository;

+        this.historicalAlarmsAndEventsRepository = historicalAlarmsAndEventsRepository;

+    }

+

+    @Override

+    public List<ActiveAlarmsAndEvents> getActiveAlarmsAndEventsByDate(Date startDate, Date endDate) {

+        return activeAlarmsAndEventsRepository.findAllActiveAlarmsAndEventsByDateLessThanEqualAndDateGreaterThanEqual

+                (endDate,startDate);

+    }

+

+    @Override

+    public List<HistoricalAlarmsAndEvents> getHistoricalAlarmsAndEventsByDate(Date startDate, Date endDate) {

+        return historicalAlarmsAndEventsRepository.findAllHistoricalAlarmsAndEventsByDateLessThanEqualAndDateGreaterThanEqual(endDate,startDate);

+

+    }

+

+    @Override

+    public void addOrUpdate(AlarmsAndEvents alarmsAndEvents) {

+       switch (alarmsAndEvents.getAlarmStatus()){

+           case ACTIVE:

+               add(new ActiveAlarmsAndEvents(alarmsAndEvents),activeAlarmsAndEventsRepository);

+               add(new HistoricalAlarmsAndEvents(alarmsAndEvents),historicalAlarmsAndEventsRepository);

+               break;

+           case DEACTIVE:

+               remove(alarmsAndEvents.getId(),activeAlarmsAndEventsRepository,AlarmsAndEvents.class);

+               add(new HistoricalAlarmsAndEvents(alarmsAndEvents) ,historicalAlarmsAndEventsRepository);

+               break;

+           default:

+               throw new UnknownTypeException("alarm status is unknown" + alarmsAndEvents.getAlarmStatus());

+       }

+    }

+}

diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/BroadBandServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/BroadBandServiceImpl.java
new file mode 100644
index 0000000..fa0fdbc
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/BroadBandServiceImpl.java
@@ -0,0 +1,115 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import org.onap.osam.model.dao.SpeedProfile;

+import org.onap.osam.model.dao.Service;

+import org.onap.osam.model.dao.TechnologyProfile;

+import org.onap.osam.model.repository.ServiceRepository;

+import org.onap.osam.model.repository.SpeedProfileRepository;

+import org.onap.osam.model.repository.TechnologyProfileRepository;

+import org.onap.osam.api.service.BroadBandService;

+import org.springframework.beans.factory.annotation.Autowired;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@org.springframework.stereotype.Service

+public class BroadBandServiceImpl extends AbstractBaseServiceImpl implements BroadBandService {

+    private SpeedProfileRepository speedProfileRepository;

+    private TechnologyProfileRepository technologyProfileRepository;

+    private ServiceRepository serviceRepository;

+

+    @Autowired

+    public BroadBandServiceImpl(SpeedProfileRepository speedProfileRepository,

+                                TechnologyProfileRepository technologyProfileRepository,

+                                ServiceRepository serviceRepository) {

+        super();

+        this.speedProfileRepository = speedProfileRepository;

+        this.technologyProfileRepository = technologyProfileRepository;

+        this.serviceRepository = serviceRepository;

+    }

+

+    @Override

+    public SpeedProfile addSpeedProfile(SpeedProfile speedProfile) {

+        return add(speedProfile, speedProfileRepository);

+    }

+

+    @Override

+    public TechnologyProfile addTechnologyProfile(TechnologyProfile technologyProfile) {

+        return add(technologyProfile,technologyProfileRepository);

+    }

+

+    @Override

+    public Service addService(Service service) {

+        return add(service,serviceRepository);

+    }

+

+    @Override

+    public void removeSpeedProfile(Long id) {

+        remove(id, speedProfileRepository, SpeedProfile.class);

+

+    }

+

+    @Override

+    public void removeTechnologyProfile(Long id) {

+        remove(id, technologyProfileRepository, TechnologyProfile.class);

+    }

+

+    @Override

+    public void removeService(Long id) {

+        remove(id, serviceRepository, Service.class);

+    }

+

+    @Override

+    public SpeedProfile getSpeedProfile(Long id) {

+        return get(id, speedProfileRepository);

+    }

+

+    @Override

+    public TechnologyProfile getTechnologyProfile(Long id) {

+        return get(id, technologyProfileRepository);

+    }

+

+    @Override

+    public Service getService(Long id) {

+        return get(id, serviceRepository);

+    }

+

+    @Override

+    public List<SpeedProfile> getSpeedProfiles() {

+        return getAll(speedProfileRepository);

+    }

+

+    @Override

+    public List<TechnologyProfile> getTechnologyProfiles() {

+        return getAll(technologyProfileRepository);

+    }

+

+    @Override

+    public List<Service> getServices() {

+        return getAll(serviceRepository);

+    }

+}

diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/DeviceServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/DeviceServiceImpl.java
new file mode 100644
index 0000000..0d6828f
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/DeviceServiceImpl.java
@@ -0,0 +1,312 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import com.google.common.collect.Lists;

+import org.onap.osam.api.service.AccessPodService;

+import org.onap.osam.common.exception.AbstractOLTException;

+import org.onap.osam.common.exception.InvalidOperationException;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.api.service.DeviceService;

+import org.onap.osam.common.exception.ServerException;

+import org.onap.osam.external.grpc.AbstractOLTClient;

+import org.onap.osam.model.dao.*;

+import org.onap.osam.model.repository.ChassisRepository;

+import org.onap.osam.model.repository.OLTPortRepository;

+import org.onap.osam.model.repository.OLTSlotRepository;

+import org.onap.osam.model.repository.ONTDeviceRepository;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.stereotype.Service;

+

+import java.util.HashSet;

+import java.util.List;

+import java.util.Optional;

+import java.util.Set;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+@Service

+public class DeviceServiceImpl extends AbstractBaseServiceImpl implements DeviceService {

+

+    private ChassisRepository chassisRepository;

+    private OLTPortRepository oltPortRepository;

+    private OLTSlotRepository oltSlotRepository;

+    private ONTDeviceRepository ontDeviceRepository;

+    private AbstractOLTClient abstractOLTClient;

+    private AccessPodService accessPodService;

+

+    public static int NUMBER_OF_OLT_PORTS   = 16;

+    public static int NUMBER_OF_ONT_DEVICES = 64;

+

+    @Autowired

+    public DeviceServiceImpl(ChassisRepository chassisRepository,

+                             OLTPortRepository oltPortRepository,

+                             OLTSlotRepository oltSlotRepository,

+                             ONTDeviceRepository ontDeviceRepository,

+                             AbstractOLTClient abstractOLTClient,

+                             AccessPodService accessPodService) {

+        this.chassisRepository = chassisRepository;

+        this.oltPortRepository = oltPortRepository;

+        this.oltSlotRepository = oltSlotRepository;

+        this.ontDeviceRepository = ontDeviceRepository;

+        this.abstractOLTClient = abstractOLTClient;

+        this.accessPodService = accessPodService;

+    }

+

+    @Override

+    public Chassis addChassis(Chassis chassis) {

+        AccessPod accessPod = accessPodService.findByPnfId(chassis.getAccessPod().getPnfId());

+        chassis.setAccessPod(accessPod);

+        abstractOLTClient.createChassis(chassis);

+        return add(chassis, chassisRepository);

+    }

+

+    @Override

+    public void deleteChassis(Long id) {

+        log.info("Deleting chassis, id: {}", id);

+        remove(id, chassisRepository,Chassis.class);

+    }

+

+    public void deleteChassisByClli(String clli) {

+        Optional<Chassis> chassis = chassisRepository.findByClli(clli);

+        if (chassis.isPresent()){

+            Long id = chassis.get().getId();

+            log.trace("Deleting chassis, clli: {}", clli);

+            remove(id, chassisRepository,Chassis.class);

+        } else {

+            log.error("Chassis not found for clli {}, nothing to delete", clli);

+            throw new NotFoundException("Chassis not found for clli {}",clli);

+        }

+    }

+

+    @Override

+    public Chassis getChassisById(Long id) {

+        Optional<Chassis> chassis = chassisRepository.findById(id);

+        if (!chassis.isPresent()) {

+            log.error("Chassis not found for id {}", id);

+            throw new NotFoundException("Chassis not found for id {}",id);

+        }

+        return chassis.get();

+    }

+

+    @Override

+    public Chassis getChassisByClli(String clli) {

+        Optional<Chassis> chassis = chassisRepository.findByClli(clli);

+        if (!chassis.isPresent()) {

+            log.error("Chassis not found for clli {}", clli);

+            throw new NotFoundException("Chassis not found for clli {}",clli);

+        }

+        return chassis.get();

+    }

+

+    @Override

+    public Long getChassisCount() {

+        return chassisRepository.count();

+    }

+

+    @Override

+    public List<Chassis> getByPnfId(String pnfId) {

+        Optional<List<Chassis>> chassisList = chassisRepository.findByAccessPodPnfId(pnfId);

+        if (!chassisList.isPresent()) {

+            log.error("Chassis is not found with pnfId {}", pnfId);

+            throw new NotFoundException("Chassis is not found with pnfId : {}",pnfId);

+        }

+        return chassisList.get();

+    }

+

+    @Override

+    public List<Chassis> getAllChassis() {

+        return Lists.newArrayList(chassisRepository.findAll());

+    }

+

+    @Override

+    public OLTSlot addOLTSlot(OLTSlot oltSlot, Chassis chassis) {

+        Set<OLTSlot> oltSlots = Optional.ofNullable(chassis.getOltSlots()).orElse(new HashSet<>());

+        int size = oltSlots.size();

+        if (size == NUMBER_OF_OLT_PORTS) {

+            log.error("Maximum number of OLTs exceeded, max size per chassis: {}", NUMBER_OF_OLT_PORTS);

+            throw new InvalidOperationException("Maximum number of OLTs exceeded");

+        }

+        oltSlot.setNumber(size+1);

+        oltSlot.setAdminState(AdminState.ENABLED);

+        oltSlot.setOperationalState(ActivityState.ACTIVE);

+        oltSlot.setPortAuthState(ActivityState.ACTIVE);

+        abstractOLTClient.createOLTChassis(oltSlot);

+

+        oltSlot.setChassis(chassis);

+        log.trace("Adding OLT Slot, OLT slot: {}", oltSlot);

+        add(oltSlot, oltSlotRepository);

+        for (int j = 0; j < 16 ; j++) {

+            OLTPort oltPort = new OLTPort();

+            oltPort.setOltSlot(oltSlot);

+            oltPort.setPortNumber(j+1);

+            oltPort.setAdminState(AdminState.ENABLED);

+            oltPort.setPortAuthState(ActivityState.ACTIVE);

+            log.trace("Adding OLT Port on this slot, OLT port: {}", oltPort);

+            add(oltPort, oltPortRepository);

+        }

+        oltSlots.add(oltSlot);

+        chassis.setOltSlots(oltSlots);

+        log.trace("Adding this OLT slot to chassis {}", chassis);

+        chassisRepository.save(chassis);

+        return oltSlot;

+    }

+

+    @Override

+    public void deleteOLTSlot(Long id) {

+        log.info("Deleting OLT slot, id: {}", id);

+        oltSlotRepository.deleteById(id);

+    }

+

+    @Override

+    public OLTSlot getOLTSlotById(Long id) {

+        Optional<OLTSlot> oltSlot = oltSlotRepository.findById(id);

+        if (!oltSlot.isPresent()) {

+            log.error("OLT Slot not found with id {}", id);

+            throw new NotFoundException("OLT Slot not found with id "+id);

+        }

+        return oltSlot.get();

+    }

+

+    @Override

+    public OLTSlot getOLTSlotBySerialNumber(String serialNumber) {

+        Optional<OLTSlot> oltSlot = oltSlotRepository.findBySerialNumber(serialNumber);

+        if (!oltSlot.isPresent()) {

+            log.error("OLT Slot not found with serial number {}", serialNumber);

+            throw new NotFoundException("OLT Slot not found with serialNumber {}",serialNumber);

+        }

+        return oltSlot.get();

+    }

+

+    @Override

+    public List<OLTSlot> getAllOLTSlots() {

+        return Lists.newArrayList(oltSlotRepository.findAll());

+    }

+

+    @Override

+    public void deleteOLTPort(Long id) {

+        log.info("Deleting OLT port, id: {}", id);

+        oltPortRepository.deleteById(id);

+    }

+

+    @Override

+    public OLTPort getOLTPortById(Long id) {

+        Optional<OLTPort> oltPort = oltPortRepository.findById(id);

+        if (!oltPort.isPresent()) {

+            log.error("OLT Port not found, id: {}", id);

+            throw new NotFoundException("OLT Port not found, id {}",id);

+        }

+        return oltPort.get();

+    }

+

+    @Override

+    public ONTDevice provisionONTDevice(ONTDevice ont, OntProvisioningType provisioningType){

+        log.trace("ONT Device provisioning, ONT Device: {}, provisioning type: ");

+        OLTPort oltPort = ont.getOLTPort();

+        int portNumber = oltPort.getPortNumber();

+        OLTSlot oltSlot = oltPort.getOltSlot();

+        int slotNumber = oltSlot.getNumber();

+        Chassis chassis = oltSlot.getChassis();

+        String clli = chassis.getClli();

+        int ontNumber = ont.getNumber();

+        String serialNumber = ont.getSerialNumber();

+        Optional<OLTPort> thePort = oltPortRepository.findByPortNumberAndOltSlot_NumberAndOltSlot_ChassisClli(portNumber,slotNumber,clli);

+        if (thePort.isPresent()) {

+            OLTPort port = thePort.get();

+            log.trace("Port found : {}", thePort);

+            Set<ONTDevice> ontDevices = Optional.ofNullable(port.getOntDevices()).orElse(new HashSet<>());

+

+            ONTDevice ontDevice = new ONTDevice();

+            ontDevice.setSerialNumber(serialNumber);

+            ontDevice.setNumber(ontNumber);

+            ontDevice.setOLTPort(port);

+            ontDevice.setAdminState(AdminState.ENABLED);

+            ontDevice.setOperationalState(ActivityState.ACTIVE);

+            ontDevice.setPortAuthState(ActivityState.ACTIVE);

+            ontDevice.setCTag(ont.getCTag());

+            ontDevice.setSTag(ont.getSTag());

+            ontDevice.setCircuitId(ont.getCircuitId());

+            ontDevice.setNasPortId(ont.getNasPortId());

+

+            //TODO Handle technology and speed profiles later

+            ontDevice.setSpeedProfile(null);

+            ontDevice.setTechProfile(null);

+

+            boolean success =  false;

+            if (provisioningType == OntProvisioningType.FULL) {

+                success = abstractOLTClient.provisionOntFull(ont);

+            } else if (provisioningType == OntProvisioningType.PREPROVISION) {

+                success = abstractOLTClient.preProvisionOnt(ont);

+            } else {

+                success = abstractOLTClient.provisionONT(ont);

+            }

+

+            if (success){

+                ontDevice = add(ontDevice, ontDeviceRepository);

+                ontDevices.add(ontDevice);

+                port.setOntDevices(ontDevices);

+                oltPortRepository.save(port);

+            } else {

+                log.error("Failed to process ONTDevice at Abstract OLT, ONTDevice: {}", ont);

+                throw new ServerException("Failed to provision ONTDevice with serial number " + ont.getSerialNumber());

+            }

+

+        } else {

+            log.error("Port not found, port number: {}", portNumber);

+            throw new NotFoundException("Port not found, port number {}",portNumber);

+        }

+        return ont;

+    }

+

+    @Override

+    public void deleteONTDevice(Long id) {

+        log.info("Deleting ONT device port, id: {}", id);

+        ontDeviceRepository.deleteById(id);

+    }

+

+    @Override

+    public ONTDevice getONTDeviceById(Long id) {

+        Optional<ONTDevice> ontDevice = ontDeviceRepository.findById(id);

+        if (!ontDevice.isPresent()) {

+            log.error("Couldn't find ONT Device with ID {}", id);

+            throw new NotFoundException("Couldn't find ONT Device with ID {}",id);

+        }

+        return ontDevice.get();

+    }

+

+    @Override

+    public ONTDevice getONTDeviceBySerialNumber(String serialNumber) {

+        Optional<ONTDevice> ontDevice = ontDeviceRepository.findBySerialNumber(serialNumber);

+        if (!ontDevice.isPresent()) {

+            log.error("Couldn't find ONT Device with serialNumber {}", serialNumber);

+            throw new NotFoundException("Couldn't find ONT Device with serialNumber {}",serialNumber);

+        }

+        return ontDevice.get();

+    }

+

+    @Override

+    public List<ONTDevice> getAllONTDevices() {

+        return Lists.newArrayList(ontDeviceRepository.findAll());

+    }

+}

diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/PmConfigsServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/PmConfigsServiceImpl.java
new file mode 100644
index 0000000..b1e3f29
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/PmConfigsServiceImpl.java
@@ -0,0 +1,104 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import org.onap.osam.model.repository.PmConfigsRepository;

+import org.onap.osam.model.dao.PmConfig;

+import org.onap.osam.model.dao.PmConfigs;

+import org.onap.osam.model.dao.PmGroupConfig;

+import org.onap.osam.model.repository.PmConfigRepository;

+import org.onap.osam.model.repository.PmGroupConfigRepository;

+import org.onap.osam.api.service.PmConfigsService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.stereotype.Service;

+

+import java.util.List;

+

+@Service

+public class PmConfigsServiceImpl extends AbstractBaseServiceImpl implements PmConfigsService{

+

+    protected PmConfigRepository pmConfigRepository;

+    protected PmConfigsRepository pmConfigsRepository;

+    protected PmGroupConfigRepository pmGroupConfigRepository;

+

+    @Autowired

+    public PmConfigsServiceImpl(PmConfigRepository pmConfigRepository,PmConfigsRepository pmConfigsRepository,

+                                PmGroupConfigRepository pmGroupConfigRepository){

+

+        this.pmConfigRepository=pmConfigRepository;

+        this.pmGroupConfigRepository=pmGroupConfigRepository;

+        this.pmConfigsRepository=pmConfigsRepository;

+    }

+

+

+    @Override

+    public List<PmConfig> getPmConfigByPmConfigsId(Long pmConfigsId) {

+        return pmConfigRepository.getByPmConfigs_Id(pmConfigsId);

+    }

+

+    @Override

+    public List<PmConfig> getPmConfigByPmConfigGroupId(Long pmGroupConfigsId) {

+        return pmConfigRepository.getByPmGroupConfig_Id(pmGroupConfigsId);

+    }

+

+    @Override

+    public void addPmGroupConfig(PmConfig pmConfig) {

+        add(pmConfig,pmConfigRepository);

+    }

+

+    @Override

+    public void addPmGroupConfig(PmGroupConfig pmGroupConfig) {

+        add(pmGroupConfig,pmGroupConfigRepository);

+    }

+

+    @Override

+    public void removePmConfig(Long pmConfigId) {

+        remove(pmConfigId,pmConfigRepository,PmConfig.class);

+    }

+

+    @Override

+    public void removeGroupPmConfig(Long pmGroupConfigId) {

+        remove(pmGroupConfigId,pmGroupConfigRepository,PmGroupConfig.class);

+    }

+

+

+    @Override

+    public PmConfigs addOrUpdate(PmConfigs value) {

+        return add(value,pmConfigsRepository);

+    }

+

+    @Override

+    public void removeById(Long key) {

+        remove(key,pmConfigsRepository,PmConfigs.class);

+    }

+

+    @Override

+    public PmConfigs getById(Long key) {

+        return get(key,pmConfigsRepository);

+    }

+

+    @Override

+    public List<PmConfigs> getAll() {

+        return getAll(pmConfigsRepository);

+    }

+}

diff --git a/osam-core-framework/core/src/main/java/org/onap/osam/core/SubscriberServiceImpl.java b/osam-core-framework/core/src/main/java/org/onap/osam/core/SubscriberServiceImpl.java
new file mode 100644
index 0000000..e295655
--- /dev/null
+++ b/osam-core-framework/core/src/main/java/org/onap/osam/core/SubscriberServiceImpl.java
@@ -0,0 +1,71 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.core;

+

+import org.onap.osam.model.dao.Subscriber;

+import org.onap.osam.model.repository.SubscriberRepository;

+import org.onap.osam.api.service.SubscriberService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.stereotype.Service;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@Service

+public class SubscriberServiceImpl extends AbstractBaseServiceImpl implements SubscriberService {

+

+    private SubscriberRepository subscriberRepository;

+

+    @Autowired

+    public SubscriberServiceImpl(SubscriberRepository subscriberRepository) {

+        this.subscriberRepository = subscriberRepository;

+    }

+

+    @Override

+    public Subscriber addOrUpdate(Subscriber subscriber) {

+        //TODO Add Check the devices.....

+        return add(subscriber, subscriberRepository);

+    }

+

+    @Override

+    public void removeById(Long id) {

+        remove(id, subscriberRepository, Subscriber.class);

+    }

+

+    @Override

+    public Subscriber getById(Long id) {

+        return get(id, subscriberRepository);

+    }

+

+    @Override

+    public List<Subscriber> getAll() {

+        return getAll(subscriberRepository);

+    }

+

+    @Override

+    public Subscriber getBySubscriberIdentifier(String userIdentifier) {

+        return subscriberRepository.findByUserIdentifier(userIdentifier);

+    }

+}

diff --git a/osam-core-framework/core/src/test/java/org/onap/osam/core/DeviceServiceImplTest.java b/osam-core-framework/core/src/test/java/org/onap/osam/core/DeviceServiceImplTest.java
new file mode 100644
index 0000000..3b974a5
--- /dev/null
+++ b/osam-core-framework/core/src/test/java/org/onap/osam/core/DeviceServiceImplTest.java
@@ -0,0 +1,440 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+package org.onap.osam.core;

+

+import junitparams.JUnitParamsRunner;

+import junitparams.Parameters;

+import org.junit.Before;

+import org.junit.Test;

+import org.junit.runner.RunWith;

+import org.mockito.ArgumentCaptor;

+import org.mockito.Captor;

+import org.mockito.InjectMocks;

+import org.mockito.Mock;

+import org.mockito.MockitoAnnotations;

+import org.onap.osam.api.service.AccessPodService;

+import org.onap.osam.api.service.DeviceService;

+import org.onap.osam.common.exception.AbstractOLTException;

+import org.onap.osam.common.exception.InvalidOperationException;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.common.exception.ServerException;

+import org.onap.osam.external.grpc.AbstractOLTClient;

+import org.onap.osam.model.dao.*;

+import org.onap.osam.model.repository.ChassisRepository;

+import org.onap.osam.model.repository.OLTPortRepository;

+import org.onap.osam.model.repository.OLTSlotRepository;

+import org.onap.osam.model.repository.ONTDeviceRepository;

+

+import java.util.ArrayList;

+import java.util.HashSet;

+import java.util.List;

+import java.util.Optional;

+import java.util.Set;

+

+import static org.assertj.core.api.Assertions.assertThat;

+import static org.assertj.core.api.Assertions.assertThatThrownBy;

+import static org.mockito.ArgumentMatchers.any;

+import static org.mockito.Mockito.*;

+

+/**

+ * Created by Zafer Kaban on 26.11.2018.

+ */

+

+@RunWith(JUnitParamsRunner.class)

+public class DeviceServiceImplTest {

+

+    private static String TEST_PNF_ID = "TEST_PNF_ID";

+    private static String TEST_CLLI   = "TEST_CLLI";

+    private static String TEST_SERIAL = "SERIAL_NUMBER";

+

+    @Mock

+    private ChassisRepository chassisRepository;

+    @Mock

+    private OLTPortRepository oltPortRepository;

+    @Mock

+    private OLTSlotRepository oltSlotRepository;

+    @Mock

+    private ONTDeviceRepository ontDeviceRepository;

+

+    @Mock

+    private AbstractOLTClient abstractOLTClient;

+

+    @Mock

+    private AccessPodService accessPodService;

+

+    @Captor

+    private ArgumentCaptor<ONTDevice> ontDeviceCaptor;

+

+    @Captor

+    private ArgumentCaptor<OLTPort> portCaptor;

+

+

+    private Chassis chassis;

+

+    private AccessPod accessPod;

+

+    private OLTSlot oltSlot;

+

+    private OLTPort oltPort;

+

+    private ONTDevice ontDevice;

+

+    @InjectMocks

+    private DeviceServiceImpl deviceService;

+

+    @Before

+    public void initMocks() {

+        MockitoAnnotations.initMocks(this);

+        accessPod = new AccessPod();

+        accessPod.setPnfId(TEST_PNF_ID);

+        chassis = new Chassis();

+        chassis.setClli(TEST_CLLI);

+        chassis.setAccessPod(accessPod);

+        chassis.setId(1L);

+        oltSlot = new OLTSlot();

+        oltSlot.setId(1L);

+        oltSlot.setNumber(1);

+        oltPort = new OLTPort();

+        oltPort.setId(1L);

+        oltPort.setPortNumber(1);

+        ontDevice = new ONTDevice();

+        ontDevice.setId(1L);

+        ontDevice.setOLTPort(oltPort);

+        oltPort.setOltSlot(oltSlot);

+        oltSlot.setChassis(chassis);

+

+        when(chassisRepository.findByClli(TEST_CLLI)).thenReturn(Optional.ofNullable(chassis));

+        when(chassisRepository.findById(1L)).thenReturn(Optional.ofNullable(chassis));

+    }

+

+    @Test

+    public void whenAddChassis_sunnyFlow(){

+

+        // TEST Sunshine scenario

+        when(accessPodService.findByPnfId(TEST_PNF_ID)).thenReturn(accessPod);

+        when(chassisRepository.save(chassis)).thenReturn(chassis);

+

+        Chassis chassisResult = deviceService.addChassis(chassis);

+        assertThat(chassisResult).isSameAs(chassis);

+    }

+

+

+    @Test

+    public void whenAddChassisPnfNotFound_shouldThrowException() {

+        // TEST when PNF registration does not exist so that Access POD does not exist in OSAM DB

+

+        when(accessPodService.findByPnfId(TEST_PNF_ID)).thenThrow(NotFoundException.class);

+        assertThatThrownBy(() -> deviceService.addChassis(chassis)).isInstanceOf(NotFoundException.class);

+        //verify we save nothing to DB

+        verifyZeroInteractions(chassisRepository);

+    }

+

+    @Test

+    public void whenAddChassisAbstractOltReturnsNull_shouldThrowException() {

+        // TEST grpc failure case

+

+        when(accessPodService.findByPnfId(TEST_PNF_ID)).thenReturn(accessPod);

+        doThrow(AbstractOLTException.class).when(abstractOLTClient).createChassis(chassis);

+        assertThatThrownBy(() -> deviceService.addChassis(chassis)).isInstanceOf(AbstractOLTException.class);

+        //verify we save nothing to DB

+        verifyZeroInteractions(chassisRepository);

+    }

+

+

+    @Test

+    public void whenDeleteChassisById_sunnyFlow() {

+        deviceService.deleteChassis(1L);

+        verify(chassisRepository, times(1)).deleteById(1L);

+    }

+

+    @Test

+    public void whenDeleteChassisByClli_sunnyFlow () {

+        deviceService.deleteChassisByClli(TEST_CLLI);

+        //Test chassis has clli TEST_CLLI and id 1L, thus the verify

+        verify(chassisRepository, times(1)).deleteById(1L);

+    }

+

+

+

+    @Test

+    public void whenGetChassisById_sunnyFlow(){

+        Chassis testChassis = deviceService.getChassisById(1L);

+        assertThat(testChassis).isSameAs(chassis);

+    }

+

+    @Test

+    public void whenGetChassisByNotExistingId_throwNotFoundException(){

+        assertThatThrownBy(() -> deviceService.getChassisById(100L)).isInstanceOf(NotFoundException.class);

+    }

+

+    @Test

+    public void whenGetChassisByTestClli_sunnyFlow(){

+        Chassis testChassis = deviceService.getChassisByClli(TEST_CLLI);

+        assertThat(testChassis).isSameAs(chassis);

+    }

+

+    @Test

+    public void whenGetChassisByNotExistingClli_throwNotFoundException(){

+        assertThatThrownBy(() -> deviceService.getChassisByClli("SOME_FAKE_CLLI")).isInstanceOf(NotFoundException.class);

+    }

+

+    @Test

+    public void whenCountChassis_sunnyFlow(){

+        when(chassisRepository.count()).thenReturn(1L);

+        long count = deviceService.getChassisCount();

+        assertThat(count).isEqualTo(1L);

+    }

+

+    @Test

+    public void whenGetByPnfId_sunnyFlow(){

+        when(chassisRepository.findByAccessPodPnfId(TEST_PNF_ID)).thenReturn(Optional.of(new ArrayList<Chassis>()));

+        ArrayList<Chassis> chassisResult = (ArrayList<Chassis>) deviceService.getByPnfId(TEST_PNF_ID);

+        assertThat(chassisResult).isNotNull();

+    }

+

+

+    @Test

+    public void whenGetByPnfIdNotExisting_shouldThrowException(){

+        assertThatThrownBy(() -> deviceService.getByPnfId("SOME_FAKE_PNFID")).isInstanceOf(NotFoundException.class);

+    }

+

+

+    @Test

+    public void whenGetAllChassis_sunnyFlow() {

+        when(chassisRepository.findAll()).thenReturn(new ArrayList<Chassis>());

+        ArrayList<Chassis> chassisResult = (ArrayList<Chassis>) deviceService.getAllChassis();

+        assertThat(chassisResult).isNotNull();

+    }

+

+

+    @Test

+    public void whenAddOLTSlot_sunnyFlow() {

+

+        Set<OLTSlot> oltSlots = new HashSet<OLTSlot>();

+        chassis.setOltSlots(oltSlots);

+        when(oltSlotRepository.save(oltSlot)).thenReturn(oltSlot);

+        when(abstractOLTClient.createOLTChassis(oltSlot)).thenReturn(TEST_CLLI);

+

+        OLTSlot oltResult = deviceService.addOLTSlot(oltSlot, chassis);

+

+        //verify creation of 16 ports

+        verify(oltPortRepository, times(16)).save(portCaptor.capture());

+        final List<OLTPort> allOltPortsValues = portCaptor.getAllValues();

+        allOltPortsValues.forEach(x -> {

+            assertThat(x.getOltSlot()).isSameAs(oltSlot);

+            assertThat(x.getAdminState()).isEqualTo(AdminState.ENABLED);

+            assertThat(x.getPortAuthState()).isEqualTo(ActivityState.ACTIVE);

+        });

+

+        //verify added to chassis

+        assertThat(chassis.getOltSlots()).hasSize(1);

+

+        //verify oltSlot logic

+        assertThat(oltResult).isSameAs(oltSlot);

+        assertThat(oltResult.getAdminState()).isEqualTo(AdminState.ENABLED);

+        assertThat(oltResult.getOperationalState()).isEqualTo(ActivityState.ACTIVE);

+        assertThat(oltResult.getPortAuthState()).isEqualTo(ActivityState.ACTIVE);

+

+    }

+

+    public void whenAddOLTSlotTooManySlotsOnChassis_shouldThrowException() {

+        //already add 16 slots, cannot add another one

+        Set<OLTSlot> oltSlots = new HashSet<OLTSlot>();

+        for (int i = 0; i < 16; i++) {

+            oltSlots.add(new OLTSlot());

+        }

+        chassis.setOltSlots(oltSlots);

+        assertThatThrownBy(()-> deviceService.addOLTSlot(oltSlot, chassis)).isInstanceOf(InvalidOperationException.class);

+        //verify no DB interactions

+        verifyZeroInteractions(oltSlotRepository, oltPortRepository, chassisRepository);

+    }

+

+    public void whenAddOLTSlotAbstractOLTReturnsNull_shouldThrowException() {

+        when(abstractOLTClient.createOLTChassis(oltSlot)).thenReturn(null);

+        assertThatThrownBy(()-> deviceService.addOLTSlot(oltSlot, chassis)).isInstanceOf(ServerException.class);

+        //verify no DB interactions

+        verifyZeroInteractions(oltSlotRepository, oltPortRepository, chassisRepository);

+    }

+

+    @Test

+    public void whenDeleteOLTSlot_repositoryMethodCalledOnce() {

+        deviceService.deleteOLTSlot(1L);

+        verify(oltSlotRepository, times(1)).deleteById(1L);

+    }

+

+

+    @Test

+    public void whenGetOLTSlotById_sunnyFlow(){

+        when(oltSlotRepository.findById(1L)).thenReturn(Optional.of(oltSlot));

+        OLTSlot oltActualSlot = deviceService.getOLTSlotById(1L);

+        assertThat(oltActualSlot).isSameAs(oltSlot);

+    }

+

+    @Test

+    public void whenGetOLTSlotByIdNotExisting_shouldThrowException(){

+        assertThatThrownBy(()-> deviceService.getOLTSlotById(100L)).isInstanceOf(NotFoundException.class);

+    }

+

+    @Test

+    public void whenGetOLTSlotBySerialId_sunnyFlow() {

+        when(oltSlotRepository.findBySerialNumber(TEST_SERIAL)).thenReturn(Optional.of(oltSlot));

+        OLTSlot oltActualSlot = deviceService.getOLTSlotBySerialNumber(TEST_SERIAL);

+        assertThat(oltActualSlot).isSameAs(oltSlot);

+    }

+

+    @Test

+    public void whenGetOLTSlotBySerialIdNotExisting_shouldThrowException(){

+        assertThatThrownBy(()-> deviceService.getOLTSlotBySerialNumber("SOME_FAKE_SERIAL")).isInstanceOf(NotFoundException.class);

+    }

+

+    @Test

+    public void whenGetAllOLTSlot_sunnyFlow() {

+        final ArrayList<OLTSlot> slotArrayList = new ArrayList<>();

+        when(oltSlotRepository.findAll()).thenReturn(slotArrayList);

+        ArrayList<OLTSlot> oltSlots = (ArrayList<OLTSlot>) deviceService.getAllOLTSlots();

+        assertThat(oltSlots).isEqualTo(slotArrayList);

+    }

+

+    @Test

+    public void whenDeleteOLTPort_sunnyFlow() {

+        deviceService.deleteOLTPort(1L);

+        verify(oltPortRepository, times(1)).deleteById(1L);

+    }

+

+    @Test

+    public void whenGetOLTPort_sunnyFlow() {

+        when(oltPortRepository.findById(1L)).thenReturn(Optional.of(oltPort));

+        final OLTPort actualPort = deviceService.getOLTPortById(1L);

+        assertThat(actualPort).isSameAs(oltPort);

+    }

+

+    @Test

+    public void whenGetOLTPortByIdNotExisting_shouldThrowException(){

+        assertThatThrownBy(()-> deviceService.getOLTPortById(100L)).isInstanceOf(NotFoundException.class);

+    }

+

+    @Test

+    @Parameters(method = "provTypeToTestForOnt")

+    public void whenProvisionONTDevice_sunnyFlow(DeviceService.OntProvisioningType provType) {

+

+

+        //setting up ontDevice

+        ontDevice.setSerialNumber("SOME_SERIAL_NUMBER");

+        ontDevice.setNumber(23);

+        ontDevice.setCTag(111);

+        ontDevice.setSTag(222);

+        ontDevice.setCircuitId("CIRCUIT_ID");

+        ontDevice.setNasPortId("NAS_PORT_ID");

+        ontDevice.setAdminState(AdminState.ENABLED);

+        ontDevice.setOperationalState(ActivityState.ACTIVE);

+        ontDevice.setPortAuthState(ActivityState.ACTIVE);

+

+        when(oltPortRepository.findByPortNumberAndOltSlot_NumberAndOltSlot_ChassisClli(1,1,TEST_CLLI)).thenReturn(Optional.ofNullable(oltPort));

+        when(abstractOLTClient.provisionONT(ontDevice)).thenReturn(true);

+        when(abstractOLTClient.preProvisionOnt(ontDevice)).thenReturn(true);

+        when(abstractOLTClient.provisionOntFull(ontDevice)).thenReturn(true);

+

+        //This is because in order to be inserted to hashset of oltSlots at the next command of tested function,

+        //the ONTDevice has to have ID

+        when(ontDeviceRepository.save(any())).thenReturn(ontDevice);

+

+       deviceService.provisionONTDevice(ontDevice, provType);

+

+       //checking that the copy to persisted object was as expected

+        verify(ontDeviceRepository, times(1)).save(ontDeviceCaptor.capture());

+        final ONTDevice capturedONTDevice = ontDeviceCaptor.getValue();

+

+        //TODO Pavel fix after discussion with Netsia regarding the returned object.

+        //Currently the assert will fail because internal object has no ID.

+        //I didn't want to use isEqualUsingSpecificFields, to catch set operations we might miss in the future

+        //assertThat(capturedONTDevice).isEqualToComparingFieldByField(ontDevice);

+

+        verify(oltPortRepository, times(1)).save(oltPort);

+    }

+

+    private Object[] provTypeToTestForOnt() {

+        return new Object[] {

+                new Object[] { DeviceService.OntProvisioningType.PROVISION },

+                new Object[] { DeviceService.OntProvisioningType.PREPROVISION },

+                new Object[] { DeviceService.OntProvisioningType.FULL }

+        };

+    }

+

+    @Test

+    @Parameters(method = "provTypeToTestForOnt")

+    public void whenAddONTDeviceNoPortFound_shouldThrowException(DeviceService.OntProvisioningType provType) {

+        when(oltPortRepository.findByPortNumberAndOltSlot_NumberAndOltSlot_ChassisClli(1,1,TEST_CLLI)).thenReturn(Optional.ofNullable(null));

+        assertThatThrownBy(()-> deviceService.provisionONTDevice(ontDevice, provType)).isInstanceOf(NotFoundException.class);

+

+    }

+

+    @Test

+    @Parameters(method = "provTypeToTestForOnt")

+    public void whenAddONTDeviceAbstractOLTError_shouldThrowException(DeviceService.OntProvisioningType provType) {

+        when(oltPortRepository.findByPortNumberAndOltSlot_NumberAndOltSlot_ChassisClli(1,1,TEST_CLLI)).thenReturn(Optional.ofNullable(oltPort));

+        when(abstractOLTClient.provisionONT(ontDevice)).thenReturn(false);

+        when(abstractOLTClient.preProvisionOnt(ontDevice)).thenReturn(false);

+        when(abstractOLTClient.provisionOntFull(ontDevice)).thenReturn(false);

+        assertThatThrownBy(()-> deviceService.provisionONTDevice(ontDevice, provType)).isInstanceOf(ServerException.class);

+

+    }

+

+    @Test

+    public void whenDeleteONTDevice_sunnyFlow() {

+        deviceService.deleteONTDevice(1L);

+        verify(ontDeviceRepository, times(1)).deleteById(1L);

+    }

+

+    @Test

+    public void whenGetONTDeviceById_sunnyFlow() {

+        when(ontDeviceRepository.findById(1L)).thenReturn(Optional.of(ontDevice));

+        ONTDevice actualOntDevice = deviceService.getONTDeviceById(1L);

+        assertThat(actualOntDevice).isSameAs(ontDevice);

+    }

+

+    @Test

+    public void whenGetONTDeviceNoId_shouldThrowException() {

+        assertThatThrownBy(()-> deviceService.getONTDeviceById(100L)).isInstanceOf(NotFoundException.class);

+

+    }

+

+    @Test

+    public void whenGetONTDeviceBySerialNumber_sunnyFlow() {

+        when(ontDeviceRepository.findBySerialNumber(TEST_SERIAL)).thenReturn(Optional.of(ontDevice));

+        ONTDevice actualOntDevice = deviceService.getONTDeviceBySerialNumber(TEST_SERIAL);

+        assertThat(actualOntDevice).isSameAs(ontDevice);

+    }

+

+    @Test

+    public void whenGetONTDeviceNoSerialNumber_shouldThrowException() {

+        assertThatThrownBy(()-> deviceService.getONTDeviceBySerialNumber(TEST_SERIAL)).isInstanceOf(NotFoundException.class);

+

+    }

+

+    @Test

+    public void whenGetAllONTDevices_sunnyFlow() {

+        final ArrayList<ONTDevice> devices = new ArrayList<>();

+        devices.add(ontDevice);

+        when(ontDeviceRepository.findAll()).thenReturn(devices);

+        ArrayList<ONTDevice> ontDevices = (ArrayList<ONTDevice>) deviceService.getAllONTDevices();

+        assertThat(ontDevices).isEqualTo(devices);

+    }

+}

diff --git a/osam-core-framework/external/pom.xml b/osam-core-framework/external/pom.xml
new file mode 100644
index 0000000..e81ff9b
--- /dev/null
+++ b/osam-core-framework/external/pom.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+

+    <artifactId>external</artifactId>

+

+    <repositories>

+        <repository>

+            <id>jcenter</id>

+            <url>https://jcenter.bintray.com/</url>

+        </repository>

+    </repositories>

+    <dependencies>

+        <dependency>

+            <groupId>org.springframework</groupId>

+            <artifactId>spring-webflux</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>org.springframework.boot</groupId>

+            <artifactId>spring-boot-starter-reactor-netty</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>org.lognet</groupId>

+            <artifactId>grpc-spring-boot-starter</artifactId>

+            <version>${grpc-spring-boot-starter.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>model</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>common</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+    </dependencies>

+    <pluginRepositories>

+        <pluginRepository>

+            <releases>

+                <updatePolicy>never</updatePolicy>

+            </releases>

+            <snapshots>

+                <enabled>false</enabled>

+            </snapshots>

+            <id>central</id>

+            <name>Central Repository</name>

+            <url>https://repo.maven.apache.org/maven2</url>

+        </pluginRepository>

+        <pluginRepository>

+            <id>protoc-plugin</id>

+            <url>https://dl.bintray.com/sergei-ivanov/maven/</url>

+        </pluginRepository>

+    </pluginRepositories>

+

+    <build>

+        <extensions>

+            <extension>

+                <groupId>kr.motd.maven</groupId>

+                <artifactId>os-maven-plugin</artifactId>

+                <version>${os-maven-plugin.version}</version>

+            </extension>

+        </extensions>

+        <plugins>

+            <!-- protobuf-maven-plugin -->

+            <plugin>

+                <groupId>org.xolstice.maven.plugins</groupId>

+                <artifactId>protobuf-maven-plugin</artifactId>

+                <version>${protobuf-maven-plugin.version}</version>

+                <configuration>

+                    <protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>

+                    <pluginId>grpc-java</pluginId>

+                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.11.0:exe:${os.detected.classifier}</pluginArtifact>

+                </configuration>

+                <executions>

+                    <execution>

+                        <goals>

+                            <goal>compile</goal>

+                            <goal>compile-custom</goal>

+                        </goals>

+                    </execution>

+                </executions>

+            </plugin>

+        </plugins>

+    </build>

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiClient.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiClient.java
new file mode 100644
index 0000000..2f7c7fd
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiClient.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai;

+

+import org.onap.osam.external.aai.model.PNF;

+

+import javax.net.ssl.SSLException;

+import java.io.IOException;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+public interface AaiClient {

+    PNF queryPnf(String name);

+    void putPnf(PNF pnf);

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiClientImpl.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiClientImpl.java
new file mode 100644
index 0000000..066f109
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiClientImpl.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.exception.BadFormatException;

+import org.onap.osam.common.exception.InvalidOperationException;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.external.aai.config.AaiConfig;

+import org.onap.osam.external.aai.exception.ExternalSystemException;

+import org.onap.osam.external.aai.model.PNF;

+import org.onap.osam.external.aai.util.AaiHeaderUtil;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.stereotype.Service;

+import org.springframework.web.reactive.function.client.ClientResponse;

+

+import javax.net.ssl.SSLException;

+

+

+/**

+ * Created by cemturker on 12.04.2018.

+ */

+

+@Service

+@Slf4j

+public class AaiClientImpl implements AaiClient {

+

+    private AaiConfig aaiConfig;

+

+    @Autowired

+    public AaiClientImpl(AaiConfig aaiConfig) {

+        this.aaiConfig = aaiConfig;

+    }

+

+    @Override

+    public PNF queryPnf(String name) {

+        try {

+            ClientResponse response = AaiWebClient.webClient(aaiConfig).build().queryPNF(name);

+            commonErrorCheck(name,response);

+            log.info("Pnf query response code {} for {} id",response.statusCode(),name);

+            if (response.statusCode().is2xxSuccessful()) {

+                return AaiHeaderUtil.convertToPnf(response.bodyToMono(String.class).block());

+            }

+        } catch (SSLException e) {

+            log.error("",e);

+        }

+        throw new InvalidOperationException("");

+    }

+

+    @Override

+    public void putPnf(PNF pnf) {

+        try {

+            ClientResponse response = AaiWebClient.webClient(aaiConfig).build().putPNF(pnf);

+            commonErrorCheck(pnf,response);

+            log.info("Pnf query response code {} for {} ",response.statusCode(),pnf);

+            if (response.statusCode().is2xxSuccessful()) {

+                return;

+            }

+        } catch (SSLException e) {

+            log.error("",e);

+        }

+        throw new InvalidOperationException("");

+    }

+

+    private <T> void commonErrorCheck(T t, ClientResponse response){

+        if (response.statusCode().is5xxServerError()) {

+            throw new ExternalSystemException("Aai error code:"+response.statusCode().value());

+        }

+        if (HttpStatus.BAD_REQUEST.equals(response.statusCode())) {

+            throw new BadFormatException("Bad format exception is received from AAI");

+        }

+        if (HttpStatus.NOT_FOUND.equals(response.statusCode())) {

+            throw new NotFoundException(t+" is not found in AAI");

+        }

+    }

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiWebClient.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiWebClient.java
new file mode 100644
index 0000000..d548715
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/AaiWebClient.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai;

+

+import io.netty.handler.ssl.SslContext;

+import io.netty.handler.ssl.SslContextBuilder;

+import io.netty.handler.ssl.util.InsecureTrustManagerFactory;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.external.aai.config.AaiConfig;

+import org.onap.osam.external.aai.model.PNF;

+import org.onap.osam.external.aai.util.AaiHeaderUtil;

+import org.springframework.http.client.reactive.ReactorClientHttpConnector;

+import org.springframework.web.reactive.function.client.ClientResponse;

+import org.springframework.web.reactive.function.client.WebClient;

+import org.springframework.web.util.DefaultUriBuilderFactory;

+import reactor.core.publisher.Mono;

+

+import javax.net.ssl.SSLException;

+import java.net.URI;

+

+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;

+

+/**

+ * Created by cemturker on 01.10.2018.

+ */

+@Slf4j

+public class AaiWebClient {

+    private AaiConfig config;

+    private WebClient webClient;

+    private AaiWebClient(AaiConfig config) {

+        this.config = config;

+    }

+

+    public static AaiWebClient webClient(AaiConfig config) {

+        return new AaiWebClient(config);

+    }

+

+    public AaiWebClient build() throws SSLException {

+        SslContext sslContext;

+        sslContext = SslContextBuilder

+                .forClient()

+                .trustManager(InsecureTrustManagerFactory.INSTANCE)

+                .build();

+        log.debug("Setting ssl context");

+

+        this.webClient =  WebClient.builder()

+                .clientConnector(new ReactorClientHttpConnector(clientOptions -> {

+                    clientOptions.sslContext(sslContext);

+                    clientOptions.disablePool();

+                }))

+                .defaultHeaders(httpHeaders -> httpHeaders.setAll(AaiHeaderUtil.headers()))

+                .filter(basicAuthentication(config.getUsername(), config.getPassword()))

+                .build();

+        return this;

+    }

+

+    public ClientResponse queryPNF(String pnfId) {

+        return this.webClient.get().uri(getUri(pnfId)).exchange().block();

+    }

+

+    public ClientResponse putPNF(PNF pnf) {

+        String aai = AaiHeaderUtil.convertPnfToString(pnf);

+        log.debug(aai);

+        return this.webClient.put()

+                .uri(getUri(pnf.getPnfName()))

+                .body(Mono.just(aai),String.class)

+                .exchange().block();

+    }

+

+    private URI getUri(String pnfName) {

+        return new DefaultUriBuilderFactory().builder().scheme(config.getProtocol())

+                .host(config.getHost()).port(config.getPort())

+                .path(config.getBasePath() + config.getPnfPath() + "/" + pnfName).build();

+    }

+

+

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/config/AaiConfig.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/config/AaiConfig.java
new file mode 100644
index 0000000..08ee7e7
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/config/AaiConfig.java
@@ -0,0 +1,66 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai.config;

+

+import lombok.Getter;

+import lombok.Setter;

+import lombok.extern.slf4j.Slf4j;

+import org.springframework.beans.factory.annotation.Value;

+import org.springframework.context.annotation.Configuration;

+import org.springframework.context.annotation.PropertySource;

+

+/**

+ * Created by cemturker on 12.04.2018.

+ */

+@Configuration

+@PropertySource("classpath:aai.properties")

+@Slf4j

+@Getter

+@Setter

+public class AaiConfig {

+    private static final String AAI_HOST = "${aai.host}";

+    private static final String AAI_PORT = "${aai.port}";

+

+    private static final String AAI_PROTOCOL = "${aai.protocol}";

+

+    private static final String AAI_USERNAME = "${aai.username}";

+    private static final String AAI_PASSWORD = "${aai.password}";

+    private static final String AAI_BASE_PATH = "${aai.base.path}";

+    private static final String AAI_PNF_PATH = "${aai.pnf.path}";

+

+    @Value(AAI_HOST)

+    private String host;

+    @Value(AAI_PORT)

+    private int port;

+    @Value(AAI_PROTOCOL)

+    private String protocol;

+    @Value(AAI_USERNAME)

+    private String username;

+    @Value(AAI_PASSWORD)

+    private String password;

+    @Value(AAI_BASE_PATH)

+    private String basePath;

+    @Value(AAI_PNF_PATH)

+    private String pnfPath;

+

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/exception/ExternalSystemException.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/exception/ExternalSystemException.java
new file mode 100644
index 0000000..157539e
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/exception/ExternalSystemException.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai.exception;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+public class ExternalSystemException extends RuntimeException {

+    public ExternalSystemException(String message) {

+        super(message);

+    }

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/model/PNF.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/model/PNF.java
new file mode 100644
index 0000000..63b9042
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/model/PNF.java
@@ -0,0 +1,51 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai.model;

+

+import com.google.gson.annotations.SerializedName;

+import lombok.Getter;

+import lombok.Setter;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+@Setter

+@Getter

+public class PNF {

+    @SerializedName("pnf-id")

+    private String pnfId;

+    @SerializedName("pnf-name")

+    private String pnfName;

+    @SerializedName("ipaddress-v4-oam")

+    private String ipaddressV4Oam;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("PNF{");

+        sb.append("pnfName='").append(pnfName).append('\'');

+        sb.append(", pnfId='").append(pnfId).append('\'');

+        sb.append(", ipaddressV4Oam='").append(ipaddressV4Oam).append('\'');

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/util/AaiHeaderUtil.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/util/AaiHeaderUtil.java
new file mode 100644
index 0000000..526a59f
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/aai/util/AaiHeaderUtil.java
@@ -0,0 +1,64 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai.util;

+

+import com.google.common.collect.ImmutableMap;

+import com.google.gson.Gson;

+import com.google.gson.GsonBuilder;

+import org.onap.osam.external.aai.model.PNF;

+import org.slf4j.Logger;

+import org.slf4j.LoggerFactory;

+import org.springframework.http.MediaType;

+

+

+import java.util.Map;

+

+/**

+ * Created by cemturker on 12.04.2018.

+ */

+public class AaiHeaderUtil {

+    private static final Logger logger = LoggerFactory.getLogger(AaiHeaderUtil.class);

+    private static final String X_FROM_APP_ID = "X-FromAppId";

+    private static final String X_TRANSACTION_ID = "X-TransactionId";

+    private static final String ACCEPT = "Accept";

+    private static final String CONTENT_TYPE = "Content-Type";

+    private AaiHeaderUtil(){}

+

+    public static Map<String, String> headers() {

+        return new ImmutableMap.Builder<String, String>()

+                .put(X_FROM_APP_ID,"OSAM")

+                .put(X_TRANSACTION_ID,"99")

+                .put(ACCEPT, MediaType.APPLICATION_JSON_VALUE)

+                .put(CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)

+                .build();

+    }

+

+    public static PNF convertToPnf(String body) {

+        return new Gson().fromJson(body, PNF.class);

+    }

+

+    public static String convertPnfToString(PNF pnf) {

+        GsonBuilder gsonBuilder = new GsonBuilder();

+        return gsonBuilder.create().toJson(pnf, PNF.class);

+    }

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTClient.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTClient.java
new file mode 100644
index 0000000..073c69f
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTClient.java
@@ -0,0 +1,233 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+/*

+ * Copyright 2015, Google Inc. All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without

+ * modification, are permitted provided that the following conditions are

+ * met:

+ *

+ *    * Redistributions of source code must retain the above copyright

+ * notice, this list of conditions and the following disclaimer.

+ *    * Redistributions in binary form must reproduce the above

+ * copyright notice, this list of conditions and the following disclaimer

+ * in the documentation and/or other materials provided with the

+ * distribution.

+ *

+ *    * Neither the name of Google Inc. nor the names of its

+ * contributors may be used to endorse or promote products derived from

+ * this software without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ */

+

+package org.onap.osam.external.grpc;

+

+import io.grpc.ManagedChannel;

+import io.grpc.ManagedChannelBuilder;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.exception.AbstractOLTException;

+import org.onap.osam.common.exception.ServerException;

+import org.onap.osam.grpc.AbstractOLTGrpc;

+import org.onap.osam.grpc.AddChassisMessage;

+import org.onap.osam.grpc.AddChassisReturn;

+import org.onap.osam.grpc.AddOLTChassisMessage;

+import org.onap.osam.grpc.AddOLTChassisReturn;

+import org.onap.osam.grpc.AddOntFullMessage;

+import org.onap.osam.grpc.AddOntMessage;

+import org.onap.osam.grpc.AddOntReturn;

+import org.onap.osam.grpc.PreProvisionOntMessage;

+import org.onap.osam.model.dao.Chassis;

+import org.onap.osam.model.dao.OLTSlot;

+import org.onap.osam.model.dao.ONTDevice;

+import org.springframework.beans.factory.annotation.Value;

+import org.springframework.context.annotation.PropertySource;

+import org.springframework.stereotype.Component;

+import org.springframework.util.StringUtils;

+

+import javax.annotation.PostConstruct;

+

+@Component

+@PropertySource("classpath:abstractolt.properties")

+@Slf4j

+public class AbstractOLTClient {

+

+  private static final String ABSTRACTOLT_HOST = "${abstractolt.host}";

+  private static final String ABSTRACTOLT_PORT = "${abstractolt.port}";

+

+  public static int NUMBER_OF_OLT_PORTS = 16;

+

+  private AbstractOLTGrpc.AbstractOLTBlockingStub blockingStub;

+  @Value(ABSTRACTOLT_HOST)

+  private String host;

+  @Value(ABSTRACTOLT_PORT)

+  private int port;

+

+  @PostConstruct

+  private void init() {

+      log.info("Abstract OLT connection properties - host: {}, port: {}", host, port);

+      ManagedChannel managedChannel = ManagedChannelBuilder

+                .forAddress(host, port).usePlaintext().build();

+

+      blockingStub = AbstractOLTGrpc.newBlockingStub(managedChannel);

+  }

+

+  /** create chassis */

+  public void createChassis(Chassis chassis) {

+      try {

+          log.info("createChassis begin, chassis: {}", chassis);

+

+          String clli = chassis.getClli();

+          int rack = chassis.getRack();

+          int shelf = chassis.getShelf();

+          String xosIP = chassis.getAccessPod().getCoreIp();

+          int port = Integer.parseInt(chassis.getAccessPod().getCorePort());

+          String user = chassis.getAccessPod().getUsername();

+          String pass = chassis.getAccessPod().getPassword();

+

+          AddChassisMessage request = AddChassisMessage.newBuilder()

+                  .setCLLI(clli)

+                  .setRack(rack)

+                  .setShelf(shelf)

+                  .setXOSIP(xosIP)

+                  .setXOSPort(port)

+                  .setXOSUser(user)

+                  .setXOSPassword(pass)

+                  .build();

+

+          log.info("AddChassisMessage message: {}", request);

+

+          AddChassisReturn response = blockingStub.createChassis(request);

+          if (!StringUtils.isEmpty(response.getDeviceID())) {

+              log.info("Chassis created in AbstractOLT with clli : {}", clli);

+          } else {

+              log.error("DeviceId of created chassis in AbstractOLT is empty or null, chassis: {}", chassis);

+              throw new ServerException("DeviceId of created chassis in AbstractOLT is empty or null");

+          }

+      } catch (RuntimeException e){

+          log.error("Chassis creation failed", e);

+          throw new AbstractOLTException("Chassis creation failed for chassis : {}", chassis);

+      }

+  }

+

+    public String createOLTChassis(OLTSlot olt) {

+

+        String deviceID = null, chassisDeviceId = null;

+

+        try {

+            log.info("createOLTChassis begin, olt:{}", olt);

+

+            String clli = olt.getChassis().getClli();

+            AddOLTChassisMessage.OltDriver oltDriver =  AddOLTChassisMessage.OltDriver.forNumber((olt.getOltDriver().ordinal()));

+            AddOLTChassisMessage.OltType oltType = AddOLTChassisMessage.OltType.forNumber((olt.getOltType().ordinal()));

+

+            AddOLTChassisMessage request = AddOLTChassisMessage.newBuilder()

+                    .setCLLI(clli)

+                    .setDriver(oltDriver)

+                    .setNumPorts(NUMBER_OF_OLT_PORTS)

+                    .setSlotPort(olt.getPort())

+                    .setSlotIP(olt.getIpAddress())

+                    .setType(oltType)

+                    .build();

+

+            log.info("AddOLTChassisMessage message: {}", request);

+            AddOLTChassisReturn response = blockingStub.createOLTChassis(request);

+            deviceID = response.getDeviceID();

+            chassisDeviceId = response.getChassisDeviceID();

+            if(!StringUtils.isEmpty(response.getDeviceID()) && !StringUtils.isEmpty(response.getChassisDeviceID())) {

+                log.info("OLT Chassis created in AbstractOLT deviceId : {} chassisDeviceId : {}",deviceID,chassisDeviceId);

+            } else {

+                log.error("Invalid return argument from AbstractOLT, deviceId : {} chassisDeviceId : {}",deviceID,chassisDeviceId);

+                throw new ServerException("DeviceId of created chassis in AbstractOLT is empty or null");

+            }

+

+        } catch (RuntimeException e) {

+            log.error("OLT Chassis creation failed", e);

+            throw new AbstractOLTException("OLT Chassis creation failed for olt : {}", olt);

+        }

+

+        return deviceID;

+    }

+

+    public boolean preProvisionOnt(ONTDevice ontDevice) {

+

+      boolean result = false;

+

+        try {

+            PreProvisionOntMessage preProvisionOntMessage = OntMessageFactory.getPreProvisionOntMessage(ontDevice);

+            AddOntReturn response = blockingStub.preProvisionOnt(preProvisionOntMessage);

+            result = response.getSuccess();

+            log.info("preProvisionOnt with device id : {} success : {}" ,ontDevice.getSerialNumber(), result);

+        } catch (RuntimeException e) {

+            log.error("preProvisionOnt RPC failed", e);

+            throw new AbstractOLTException("preProvisionOnt failed for ont : {}", ontDevice);

+        }

+      return result;

+    }

+

+    public boolean provisionONT(ONTDevice ontDevice) {

+

+        boolean result = false;

+        try {

+            AddOntMessage request = OntMessageFactory.getOntMessage(ontDevice);

+            AddOntReturn response = blockingStub.provisionOnt(request);

+            result = response.getSuccess();

+            log.info("provisionONT with device id : {} success : {}",ontDevice.getSerialNumber(), result);

+

+        } catch (RuntimeException e) {

+            log.error("provisionONT RPC failed", e);

+            throw new AbstractOLTException("provisionONT failed for ont : {}", ontDevice);

+        }

+

+        return result;

+    }

+

+    public boolean provisionOntFull(ONTDevice ontDevice) {

+

+        boolean result = false;

+

+        try {

+            AddOntFullMessage addOntFullMessage = OntMessageFactory.getOntFullMessage(ontDevice);

+            AddOntReturn response = blockingStub.provisionOntFull(addOntFullMessage);

+            result = response.getSuccess();

+            log.info("provisionOntFull with device id : {} success : {}",ontDevice.getSerialNumber(), result);

+

+        } catch (RuntimeException e) {

+            log.error("provisionOntFull RPC failed", e);

+            throw new AbstractOLTException("provisionOntFull failed for ont : {}", ontDevice);

+        }

+

+        return result;

+    }

+

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTServer.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTServer.java
new file mode 100644
index 0000000..39c21c7
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/AbstractOLTServer.java
@@ -0,0 +1,108 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+/*

+ * Copyright 2015, Google Inc. All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without

+ * modification, are permitted provided that the following conditions are

+ * met:

+ *

+ *    * Redistributions of source code must retain the above copyright

+ * notice, this list of conditions and the following disclaimer.

+ *    * Redistributions in binary form must reproduce the above

+ * copyright notice, this list of conditions and the following disclaimer

+ * in the documentation and/or other materials provided with the

+ * distribution.

+ *

+ *    * Neither the name of Google Inc. nor the names of its

+ * contributors may be used to endorse or promote products derived from

+ * this software without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ */

+

+package org.onap.osam.external.grpc;

+

+import io.grpc.stub.StreamObserver;

+import lombok.extern.slf4j.Slf4j;

+import org.lognet.springboot.grpc.GRpcService;

+import org.onap.osam.grpc.*;

+

+import java.util.UUID;

+

+/**

+ * Server that manages startup/shutdown of a {@code AbstractOLTServer} server.

+ */

+

+@GRpcService

+@Slf4j

+public class AbstractOLTServer extends AbstractOLTGrpc.AbstractOLTImplBase {

+

+    @Override

+    public void echo(EchoMessage request, StreamObserver<EchoReplyMessage> responseObserver) {

+

+    }

+

+    @Override

+    public void createChassis(AddChassisMessage request, StreamObserver<AddChassisReturn> responseObserver) {

+        AddChassisReturn response = AddChassisReturn.newBuilder()

+                .setDeviceID(request.getCLLI())

+                .build();

+        responseObserver.onNext(response);

+        responseObserver.onCompleted();

+        log.info("createChassis with clli : {}" , request.getCLLI());

+    }

+

+    @Override

+    public void createOLTChassis(AddOLTChassisMessage request, StreamObserver<AddOLTChassisReturn> responseObserver) {

+        AddOLTChassisReturn response = AddOLTChassisReturn.newBuilder()

+                .setDeviceID(UUID.randomUUID().toString())

+                .setChassisDeviceID(request.getCLLI()).build();

+        responseObserver.onNext(response);

+        responseObserver.onCompleted();

+        log.info("createOLTChassis with clli : {}" , request.getCLLI());

+    }

+

+    @Override

+    public void provisionOnt(AddOntMessage request, StreamObserver<AddOntReturn> responseObserver) {

+        AddOntReturn response = AddOntReturn.newBuilder().setSuccess(true).build();

+        responseObserver.onNext(response);

+        responseObserver.onCompleted();

+        log.info("provisionOnt success");

+    }

+

+    @Override

+    public void deleteOnt(DeleteOntMessage request, StreamObserver<DeleteOntReturn> responseObserver) {

+

+    }

+}

diff --git a/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/OntMessageFactory.java b/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/OntMessageFactory.java
new file mode 100644
index 0000000..ff89f0b
--- /dev/null
+++ b/osam-core-framework/external/src/main/java/org/onap/osam/external/grpc/OntMessageFactory.java
@@ -0,0 +1,123 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+package org.onap.osam.external.grpc;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.grpc.AddOntFullMessage;

+import org.onap.osam.grpc.AddOntMessage;

+import org.onap.osam.grpc.PreProvisionOntMessage;

+import org.onap.osam.model.dao.Chassis;

+import org.onap.osam.model.dao.OLTPort;

+import org.onap.osam.model.dao.OLTSlot;

+import org.onap.osam.model.dao.ONTDevice;

+

+@Slf4j

+public class OntMessageFactory {

+

+    public static PreProvisionOntMessage getPreProvisionOntMessage (ONTDevice ontDevice) {

+

+        OLTPort oltPort = ontDevice.getOLTPort();

+            OLTSlot oltSlot = oltPort.getOltSlot();

+            Chassis chassis = oltSlot.getChassis();

+            String clli = chassis.getClli();

+            String serialNumber = ontDevice.getSerialNumber();

+            int slotNumber = oltSlot.getNumber();

+            int portNumber = oltPort.getPortNumber();

+            int ontNumber = ontDevice.getNumber();

+            int stag = ontDevice.getSTag();

+            int ctag = ontDevice.getCTag();

+            String nasPortID = ontDevice.getNasPortId();

+            String circuitId = ontDevice.getCircuitId();

+            log.info("getPreProvisionOntMessage, clli: {}, serialNumber: {}, slotNumber: {}, portNumber:{}, ontNumber:{}, sTag:{}, cTag:{}, nasPortId:{}, circuitId:{}", clli, serialNumber, slotNumber, portNumber, ontNumber, stag, ctag,nasPortID, circuitId);

+

+            PreProvisionOntMessage preProvisionOntMessage = PreProvisionOntMessage.newBuilder()

+                    .setCLLI(clli)

+                    .setSlotNumber(slotNumber)

+                    .setPortNumber(portNumber)

+                    .setOntNumber(ontNumber)

+                    .setSTag(stag)

+                    .setCTag(ctag)

+                    .setNasPortID(nasPortID)

+                    .setCircuitID(circuitId)

+                    .build();

+            //TODO Handle technology and speed profiles later

+            log.info("PreProvisionOntMessage is {}", preProvisionOntMessage);

+            return  preProvisionOntMessage;

+

+    }

+

+

+    public static AddOntFullMessage getOntFullMessage (ONTDevice ontDevice) {

+

+        OLTPort oltPort = ontDevice.getOLTPort();

+        OLTSlot oltSlot = oltPort.getOltSlot();

+        Chassis chassis = oltSlot.getChassis();

+        String clli = chassis.getClli();

+        String serialNumber = ontDevice.getSerialNumber();

+        int slotNumber = oltSlot.getNumber();

+        int portNumber = oltPort.getPortNumber();

+        int ontNumber = ontDevice.getNumber();

+        int stag = ontDevice.getSTag();

+        int ctag = ontDevice.getCTag();

+        String nasPortID = ontDevice.getNasPortId();

+        String circuitId = ontDevice.getCircuitId();

+        log.info("getOntFullMessage, clli: {}, serialNumber: {}, slotNumber: {}, portNumber:{}, ontNumber:{}, sTag:{}, cTag:{}, nasPortId:{}, circuitId:{}", clli, serialNumber, slotNumber, portNumber, ontNumber, stag, ctag,nasPortID, circuitId);

+

+        AddOntFullMessage addOntFullMessage = AddOntFullMessage.newBuilder()

+                .setCLLI(clli)

+                .setSerialNumber(serialNumber)

+                .setSlotNumber(slotNumber)

+                .setPortNumber(portNumber)

+                .setOntNumber(ontNumber)

+                .setSTag(stag)

+                .setCTag(ctag)

+                .setNasPortID(nasPortID)

+                .setCircuitID(circuitId)

+                .build();

+        log.info("AddOntFullMessage is {}", addOntFullMessage);

+        return  addOntFullMessage;

+

+    }

+

+    public static AddOntMessage getOntMessage (ONTDevice ontDevice) {

+

+        OLTPort oltPort = ontDevice.getOLTPort();

+        OLTSlot oltSlot = oltPort.getOltSlot();

+        Chassis chassis = oltSlot.getChassis();

+        String clli = chassis.getClli();

+        String serialNumber = ontDevice.getSerialNumber();

+        int slotNumber = oltSlot.getNumber();

+        int portNumber = oltPort.getPortNumber();

+        int ontNumber = ontDevice.getNumber();

+        log.info("getOntFullMessage, clli: {}, serialNumber: {}, slotNumber: {}, portNumber:{}, ontNumber:{}", clli, serialNumber, slotNumber, portNumber, ontNumber);

+

+        AddOntMessage addOntMessage = AddOntMessage.newBuilder()

+                .setCLLI(clli)

+                .setSerialNumber(serialNumber)

+                .setSlotNumber(slotNumber)

+                .setPortNumber(portNumber)

+                .setOntNumber(ontNumber)

+                .build();

+        log.info("AddOntMessage is {}", addOntMessage);

+        return  addOntMessage;

+

+    }

+}

diff --git a/osam-core-framework/external/src/main/proto/abstract_olt_api.proto b/osam-core-framework/external/src/main/proto/abstract_olt_api.proto
new file mode 100644
index 0000000..055acd9
--- /dev/null
+++ b/osam-core-framework/external/src/main/proto/abstract_olt_api.proto
@@ -0,0 +1,222 @@
+//Copyright 2017 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.
+
+syntax = "proto3";
+package api;
+import "google/api/annotations.proto";
+
+option java_multiple_files = true;
+option java_package = "org.onap.osam.grpc";
+option java_outer_classname = "AbstractOLTProto";
+
+message EchoMessage{
+   string Ping =1;
+}
+message EchoReplyMessage{
+   string Pong =1;
+}
+
+message AddChassisMessage{
+   string CLLI =1;
+   string XOSIP =2;
+   int32 XOSPort=3;
+   string XOSUser=4;
+   string XOSPassword=5;
+   int32 Rack=6;
+   int32 Shelf=7;
+}
+message AddChassisReturn{
+   string DeviceID = 1;
+}
+message ChangeXOSUserPasswordMessage{
+   string CLLI =1;
+   string XOSUser=2;
+   string XOSPassword=3;
+}
+message ChangeXOSUserPasswordReturn{
+   bool Success=1;
+}
+
+message AddOLTChassisMessage{
+   string CLLI=1;
+   string SlotIP=2;
+   fixed32 SlotPort=3;
+   string Hostname=4;
+   fixed32 NumPorts = 5;
+   bool Activate = 6;
+   enum OltDriver {
+      openoltDriver= 0;
+      asfvolt16Driver=1;
+      adtranDriver=2;
+      tibitsDriver=3;
+   }
+   OltDriver Driver=7;
+   enum OltType{
+      edgecore=0;
+      adtran=1;
+      tibit=2;
+   }
+   OltType Type=8;
+
+}
+message AddOLTChassisReturn {
+   string DeviceID =1;
+   string ChassisDeviceID =2;
+}
+
+message AddOntMessage{
+   string CLLI=1;
+   int32 SlotNumber=2;
+   int32 PortNumber=3;
+   int32 OntNumber=4;
+   string SerialNumber=5;
+}
+message PreProvisionOntMessage{
+   string CLLI=1;
+   int32 SlotNumber=2;
+   int32 PortNumber=3;
+   int32 OntNumber=4;
+   uint32 STag=5;
+   uint32 CTag=6;
+   string NasPortID=7;
+   string CircuitID=8;
+   string TechProfile=9;
+   string SpeedProfile=10;
+}
+message AddOntFullMessage{
+   string CLLI=1;
+   int32 SlotNumber=2;
+   int32 PortNumber=3;
+   int32 OntNumber=4;
+   string SerialNumber=5;
+   uint32 STag=6;
+   uint32 CTag=7;
+   string NasPortID=8;
+   string CircuitID=9;
+}
+message AddOntReturn{
+   bool Success=1;
+}
+
+message DeleteOntMessage{
+   string CLLI=1;
+   int32 SlotNumber=2;
+   int32 PortNumber=3;
+   int32 OntNumber=4;
+   string SerialNumber=5;
+}
+message DeleteOntReturn{
+   bool Success=1;
+}
+message ReflowMessage{
+}
+message ReflowReturn{
+    bool Success=1;
+}
+message OutputMessage{
+   string Something=1;
+}
+message OutputReturn{
+   bool Success=1;
+}
+message FullInventoryMessage{
+}
+message InventoryMessage{
+   string Clli=1;
+}
+message InventoryReturn{
+   string JsonDump=1;
+}
+service AbstractOLT{
+   rpc Echo(EchoMessage) returns (EchoReplyMessage){
+      option(google.api.http)={
+        post:"/v1/Echo"
+	body:"*"
+      };
+   }
+   rpc CreateChassis(AddChassisMessage) returns (AddChassisReturn) {
+      option(google.api.http) = {
+         post: "/v1/CreateAbstractChassis"
+	 body:"*"
+      };
+   }
+   rpc ChangeXOSUserPassword(ChangeXOSUserPasswordMessage) returns(ChangeXOSUserPasswordReturn){
+      option(google.api.http)={
+        post:"/v1/ChangeXOSUserPassword"
+	body:"*"
+      };
+   }
+   rpc CreateOLTChassis(AddOLTChassisMessage) returns (AddOLTChassisReturn) {
+      option(google.api.http) = {
+         post: "/v1/CreateOLTChassis"
+	 body:"*"
+      };
+   }
+   rpc PreProvisionOnt(PreProvisionOntMessage) returns (AddOntReturn) {
+      option(google.api.http) = {
+         post:"/v1/PreProvsionOnt"
+	 body:"*"
+      };
+   }
+   rpc ActivateSerial(AddOntMessage) returns (AddOntReturn) {
+      option(google.api.http) = {
+         post:"/v1/ActivateSerial"
+	 body:"*"
+      };
+   }
+   rpc ProvisionOnt(AddOntMessage) returns (AddOntReturn) {
+      option(google.api.http) = {
+         post:"/v1/ProvsionOnt"
+	 body:"*"
+      };
+   }
+   rpc ProvisionOntFull(AddOntFullMessage) returns (AddOntReturn) {
+      option(google.api.http) = {
+         post:"/v1/ProvsionOtFull"
+	 body:"*"
+      };
+   }
+   rpc DeleteOnt(DeleteOntMessage) returns (DeleteOntReturn){
+      option(google.api.http)={
+        post:"/v1/DeleteOnt"
+	body:"*"
+      };
+   }
+   rpc Reflow(ReflowMessage)returns (ReflowReturn){
+       option(google.api.http)={
+           post:"/v1/Reflow"
+           body:"*"
+
+       };
+   }
+   rpc Output(OutputMessage)returns(OutputReturn){
+      option(google.api.http)={
+        post:"/v1/Output"
+	    body:"*"
+      };
+   }
+   rpc GetFullInventory(FullInventoryMessage)returns(InventoryReturn){
+      option(google.api.http)={
+        post:"/v1/FullInventory"
+	    body:"*"
+      };
+   }
+   rpc GetInventory(InventoryMessage)returns(InventoryReturn){
+      option(google.api.http)={
+        post:"/v1/Inventory"
+	    body:"*"
+      };
+   }
+}
+
diff --git a/osam-core-framework/external/src/main/proto/google/api/annotations.proto b/osam-core-framework/external/src/main/proto/google/api/annotations.proto
new file mode 100644
index 0000000..8430836
--- /dev/null
+++ b/osam-core-framework/external/src/main/proto/google/api/annotations.proto
@@ -0,0 +1,31 @@
+// Copyright (c) 2015, Google Inc.

+//

+// 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.

+

+syntax = "proto3";

+

+package google.api;

+

+import "google/api/http.proto";

+import "google/protobuf/descriptor.proto";

+

+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";

+option java_multiple_files = true;

+option java_outer_classname = "AnnotationsProto";

+option java_package = "com.google.api";

+option objc_class_prefix = "GAPI";

+

+extend google.protobuf.MethodOptions {

+  // See `HttpRule`.

+  HttpRule http = 72295728;

+}

diff --git a/osam-core-framework/external/src/main/proto/google/api/http.proto b/osam-core-framework/external/src/main/proto/google/api/http.proto
new file mode 100644
index 0000000..1c98236
--- /dev/null
+++ b/osam-core-framework/external/src/main/proto/google/api/http.proto
@@ -0,0 +1,370 @@
+// Copyright 2018 Google LLC.

+//

+// 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.

+//

+

+syntax = "proto3";

+

+package google.api;

+

+option cc_enable_arenas = true;

+option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";

+option java_multiple_files = true;

+option java_outer_classname = "HttpProto";

+option java_package = "com.google.api";

+option objc_class_prefix = "GAPI";

+

+

+// Defines the HTTP configuration for an API service. It contains a list of

+// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method

+// to one or more HTTP REST API methods.

+message Http {

+  // A list of HTTP configuration rules that apply to individual API methods.

+  //

+  // **NOTE:** All service configuration rules follow "last one wins" order.

+  repeated HttpRule rules = 1;

+

+  // When set to true, URL path parmeters will be fully URI-decoded except in

+  // cases of single segment matches in reserved expansion, where "%2F" will be

+  // left encoded.

+  //

+  // The default behavior is to not decode RFC 6570 reserved characters in multi

+  // segment matches.

+  bool fully_decode_reserved_expansion = 2;

+}

+

+// # gRPC Transcoding

+//

+// gRPC Transcoding is a feature for mapping between a gRPC method and one or

+// more HTTP REST endpoints. It allows developers to build a single API service

+// that supports both gRPC APIs and REST APIs. Many systems, including [Google

+// APIs](https://github.com/googleapis/googleapis),

+// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC

+// Gateway](https://github.com/grpc-ecosystem/grpc-gateway),

+// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature

+// and use it for large scale production services.

+//

+// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies

+// how different portions of the gRPC request message are mapped to the URL

+// path, URL query parameters, and HTTP request body. It also controls how the

+// gRPC response message is mapped to the HTTP response body. `HttpRule` is

+// typically specified as an `google.api.http` annotation on the gRPC method.

+//

+// Each mapping specifies a URL path template and an HTTP method. The path

+// template may refer to one or more fields in the gRPC request message, as long

+// as each field is a non-repeated field with a primitive (non-message) type.

+// The path template controls how fields of the request message are mapped to

+// the URL path.

+//

+// Example:

+//

+//     service Messaging {

+//       rpc GetMessage(GetMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//             get: "/v1/{name=messages/*"}"

+//         };

+//       }

+//     }

+//     message GetMessageRequest {

+//       string name = 1; // Mapped to URL path.

+//     }

+//     message Message {

+//       string text = 1; // The resource content.

+//     }

+//

+// This enables an HTTP REST to gRPC mapping as below:

+//

+// HTTP | gRPC

+// -----|-----

+// `GET /v1/messages/123456`  | `GetMessage(name: "messages/123456")`

+//

+// Any fields in the request message which are not bound by the path template

+// automatically become HTTP query parameters if there is no HTTP request body.

+// For example:

+//

+//     service Messaging {

+//       rpc GetMessage(GetMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//             get:"/v1/messages/{message_id}"

+//         };

+//       }

+//     }

+//     message GetMessageRequest {

+//       message SubMessage {

+//         string subfield = 1;

+//       }

+//       string message_id = 1; // Mapped to URL path.

+//       int64 revision = 2;    // Mapped to URL query parameter `revision`.

+//       SubMessage sub = 3;    // Mapped to URL query parameter `sub.subfield`.

+//     }

+//

+// This enables a HTTP JSON to RPC mapping as below:

+//

+// HTTP | gRPC

+// -----|-----

+// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))`

+//

+// Note that fields which are mapped to URL query parameters must have a

+// primitive type or a repeated primitive type or a non-repeated message type.

+// In the case of a repeated type, the parameter can be repeated in the URL

+// as `...?param=A&param=B`. In the case of a message type, each field of the

+// message is mapped to a separate parameter, such as

+// `...?foo.a=A&foo.b=B&foo.c=C`.

+//

+// For HTTP methods that allow a request body, the `body` field

+// specifies the mapping. Consider a REST update method on the

+// message resource collection:

+//

+//     service Messaging {

+//       rpc UpdateMessage(UpdateMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//           patch: "/v1/messages/{message_id}"

+//           body: "message"

+//         };

+//       }

+//     }

+//     message UpdateMessageRequest {

+//       string message_id = 1; // mapped to the URL

+//       Message message = 2;   // mapped to the body

+//     }

+//

+// The following HTTP JSON to RPC mapping is enabled, where the

+// representation of the JSON in the request body is determined by

+// protos JSON encoding:

+//

+// HTTP | gRPC

+// -----|-----

+// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`

+//

+// The special name `*` can be used in the body mapping to define that

+// every field not bound by the path template should be mapped to the

+// request body.  This enables the following alternative definition of

+// the update method:

+//

+//     service Messaging {

+//       rpc UpdateMessage(Message) returns (Message) {

+//         option (google.api.http) = {

+//           patch: "/v1/messages/{message_id}"

+//           body: "*"

+//         };

+//       }

+//     }

+//     message Message {

+//       string message_id = 1;

+//       string text = 2;

+//     }

+//

+//

+// The following HTTP JSON to RPC mapping is enabled:

+//

+// HTTP | gRPC

+// -----|-----

+// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`

+//

+// Note that when using `*` in the body mapping, it is not possible to

+// have HTTP parameters, as all fields not bound by the path end in

+// the body. This makes this option more rarely used in practice when

+// defining REST APIs. The common usage of `*` is in custom methods

+// which don't use the URL at all for transferring data.

+//

+// It is possible to define multiple HTTP methods for one RPC by using

+// the `additional_bindings` option. Example:

+//

+//     service Messaging {

+//       rpc GetMessage(GetMessageRequest) returns (Message) {

+//         option (google.api.http) = {

+//           get: "/v1/messages/{message_id}"

+//           additional_bindings {

+//             get: "/v1/users/{user_id}/messages/{message_id}"

+//           }

+//         };

+//       }

+//     }

+//     message GetMessageRequest {

+//       string message_id = 1;

+//       string user_id = 2;

+//     }

+//

+// This enables the following two alternative HTTP JSON to RPC mappings:

+//

+// HTTP | gRPC

+// -----|-----

+// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`

+// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`

+//

+// ## Rules for HTTP mapping

+//

+// 1. Leaf request fields (recursive expansion nested messages in the request

+//    message) are classified into three categories:

+//    - Fields referred by the path template. They are passed via the URL path.

+//    - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP

+//      request body.

+//    - All other fields are passed via the URL query parameters, and the

+//      parameter name is the field path in the request message. A repeated

+//      field can be represented as multiple query parameters under the same

+//      name.

+//  2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields

+//     are passed via URL path and HTTP request body.

+//  3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all

+//     fields are passed via URL path and URL query parameters.

+//

+// ### Path template syntax

+//

+//     Template = "/" Segments [ Verb ] ;

+//     Segments = Segment { "/" Segment } ;

+//     Segment  = "*" | "**" | LITERAL | Variable ;

+//     Variable = "{" FieldPath [ "=" Segments ] "}" ;

+//     FieldPath = IDENT { "." IDENT } ;

+//     Verb     = ":" LITERAL ;

+//

+// The syntax `*` matches a single URL path segment. The syntax `**` matches

+// zero or more URL path segments, which must be the last part of the URL path

+// except the `Verb`.

+//

+// The syntax `Variable` matches part of the URL path as specified by its

+// template. A variable template must not contain other variables. If a variable

+// matches a single path segment, its template may be omitted, e.g. `{var}`

+// is equivalent to `{var=*}`.

+//

+// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL`

+// contains any reserved character, such characters should be percent-encoded

+// before the matching.

+//

+// If a variable contains exactly one path segment, such as `"{var}"` or

+// `"{var=*}"`, when such a variable is expanded into a URL path on the client

+// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The

+// server side does the reverse decoding. Such variables show up in the

+// [Discovery Document](https://developers.google.com/discovery/v1/reference/apis)

+// as `{var}`.

+//

+// If a variable contains multiple path segments, such as `"{var=foo/*}"`

+// or `"{var=**}"`, when such a variable is expanded into a URL path on the

+// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded.

+// The server side does the reverse decoding, except "%2F" and "%2f" are left

+// unchanged. Such variables show up in the

+// [Discovery Document](https://developers.google.com/discovery/v1/reference/apis)

+// as `{+var}`.

+//

+// ## Using gRPC API Service Configuration

+//

+// gRPC API Service Configuration (service config) is a configuration language

+// for configuring a gRPC service to become a user-facing product. The

+// service config is simply the YAML representation of the `google.api.Service`

+// proto message.

+//

+// As an alternative to annotating your proto file, you can configure gRPC

+// transcoding in your service config YAML files. You do this by specifying a

+// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same

+// effect as the proto annotation. This can be particularly useful if you

+// have a proto that is reused in multiple services. Note that any transcoding

+// specified in the service config will override any matching transcoding

+// configuration in the proto.

+//

+// Example:

+//

+//     http:

+//       rules:

+//         # Selects a gRPC method and applies HttpRule to it.

+//         - selector: example.v1.Messaging.GetMessage

+//           get: /v1/messages/{message_id}/{sub.subfield}

+//

+// ## Special notes

+//

+// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the

+// proto to JSON conversion must follow the [proto3

+// specification](https://developers.google.com/protocol-buffers/docs/proto3#json).

+//

+// While the single segment variable follows the semantics of

+// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String

+// Expansion, the multi segment variable **does not** follow RFC 6570 Section

+// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion

+// does not expand special characters like `?` and `#`, which would lead

+// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding

+// for multi segment variables.

+//

+// The path variables **must not** refer to any repeated or mapped field,

+// because client libraries are not capable of handling such variable expansion.

+//

+// The path variables **must not** capture the leading "/" character. The reason

+// is that the most common use case "{var}" does not capture the leading "/"

+// character. For consistency, all path variables must share the same behavior.

+//

+// Repeated message fields must not be mapped to URL query parameters, because

+// no client library can support such complicated mapping.

+//

+// If an API needs to use a JSON array for request or response body, it can map

+// the request or response body to a repeated field. However, some gRPC

+// Transcoding implementations may not support this feature.

+message HttpRule {

+  // Selects a method to which this rule applies.

+  //

+  // Refer to [selector][google.api.DocumentationRule.selector] for syntax details.

+  string selector = 1;

+

+  // Determines the URL pattern is matched by this rules. This pattern can be

+  // used with any of the {get|put|post|delete|patch} methods. A custom method

+  // can be defined using the 'custom' field.

+  oneof pattern {

+    // Maps to HTTP GET. Used for listing and getting information about

+    // resources.

+    string get = 2;

+

+    // Maps to HTTP PUT. Used for replacing a resource.

+    string put = 3;

+

+    // Maps to HTTP POST. Used for creating a resource or performing an action.

+    string post = 4;

+

+    // Maps to HTTP DELETE. Used for deleting a resource.

+    string delete = 5;

+

+    // Maps to HTTP PATCH. Used for updating a resource.

+    string patch = 6;

+

+    // The custom pattern is used for specifying an HTTP method that is not

+    // included in the `pattern` field, such as HEAD, or "*" to leave the

+    // HTTP method unspecified for this rule. The wild-card rule is useful

+    // for services that provide content to Web (HTML) clients.

+    CustomHttpPattern custom = 8;

+  }

+

+  // The name of the request field whose value is mapped to the HTTP request

+  // body, or `*` for mapping all request fields not captured by the path

+  // pattern to the HTTP body, or omitted for not having any HTTP request body.

+  //

+  // NOTE: the referred field must be present at the top-level of the request

+  // message type.

+  string body = 7;

+

+  // Optional. The name of the response field whose value is mapped to the HTTP

+  // response body. When omitted, the entire response message will be used

+  // as the HTTP response body.

+  //

+  // NOTE: The referred field must be present at the top-level of the response

+  // message type.

+  string response_body = 12;

+

+  // Additional HTTP bindings for the selector. Nested bindings must

+  // not contain an `additional_bindings` field themselves (that is,

+  // the nesting may only be one level deep).

+  repeated HttpRule additional_bindings = 11;

+}

+

+// A custom pattern is used for defining custom HTTP verb.

+message CustomHttpPattern {

+  // The name of this custom HTTP verb.

+  string kind = 1;

+

+  // The path matched by this custom verb.

+  string path = 2;

+}

diff --git a/osam-core-framework/external/src/main/resources/aai.properties b/osam-core-framework/external/src/main/resources/aai.properties
new file mode 100644
index 0000000..e8abfe0
--- /dev/null
+++ b/osam-core-framework/external/src/main/resources/aai.properties
@@ -0,0 +1,7 @@
+aai.host=192.168.62.68

+aai.port=8443

+aai.protocol=https

+aai.username=AAI

+aai.password=AAI

+aai.base.path=/aai/v12

+aai.pnf.path=/network/pnfs/pnf

diff --git a/osam-core-framework/external/src/main/resources/abstractolt.properties b/osam-core-framework/external/src/main/resources/abstractolt.properties
new file mode 100644
index 0000000..07392d8
--- /dev/null
+++ b/osam-core-framework/external/src/main/resources/abstractolt.properties
@@ -0,0 +1,2 @@
+abstractolt.host=135.25.86.132

+abstractolt.port=7777

diff --git a/osam-core-framework/external/src/test/java/org/onap/osam/external/aai/AaiClientTestIT.java b/osam-core-framework/external/src/test/java/org/onap/osam/external/aai/AaiClientTestIT.java
new file mode 100644
index 0000000..aadcd00
--- /dev/null
+++ b/osam-core-framework/external/src/test/java/org/onap/osam/external/aai/AaiClientTestIT.java
@@ -0,0 +1,73 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.external.aai;

+

+import org.junit.Before;

+import org.junit.Test;

+import org.junit.runner.RunWith;

+import org.onap.osam.external.aai.config.AaiConfig;

+import org.onap.osam.external.aai.model.PNF;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.boot.test.context.SpringBootTest;

+import org.springframework.test.context.ContextConfiguration;

+import org.springframework.test.context.junit4.SpringRunner;

+

+/**

+ * Created by cemturker on 01.10.2018.

+ */

+

+@RunWith(SpringRunner.class)

+@SpringBootTest

+@ContextConfiguration(classes = {AaiConfig.class, AaiClientImpl.class})

+public class AaiClientTestIT {

+

+    @Autowired

+    private AaiClient aaiClient;

+

+    @Before

+    public void preProcess(){

+    }

+

+    @Test

+    public void aaiQueryTest(){

+        try {

+            //PNF pnf = aaiClient.queryPnf("1111");

+        }catch (Exception e) {

+            e.printStackTrace();

+        }

+    }

+

+    @Test

+    public void aaiPutTest(){

+        try {

+            PNF pnf = new PNF();

+            pnf.setPnfId("111");

+            pnf.setPnfName("1111");

+            pnf.setIpaddressV4Oam("192.168.61.24");

+            //pnf = aaiClient.putPnf(pnf);

+        }catch (Exception e) {

+            e.printStackTrace();

+        }

+    }

+

+}

diff --git a/osam-core-framework/main/pom.xml b/osam-core-framework/main/pom.xml
new file mode 100644
index 0000000..7186578
--- /dev/null
+++ b/osam-core-framework/main/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>main</artifactId>

+    <dependencies>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>web</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+    </dependencies>

+    <build>

+        <finalName>osam-core-framework-${project.version}</finalName>

+        <plugins>

+            <plugin>

+                <groupId>org.springframework.boot</groupId>

+                <artifactId>spring-boot-maven-plugin</artifactId>

+                <configuration>

+                    <skip>false</skip>

+                </configuration>

+            </plugin>

+        </plugins>

+    </build>

+

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/main/src/main/java/org/onap/osam/OsamApplication.java b/osam-core-framework/main/src/main/java/org/onap/osam/OsamApplication.java
new file mode 100644
index 0000000..fc207e4
--- /dev/null
+++ b/osam-core-framework/main/src/main/java/org/onap/osam/OsamApplication.java
@@ -0,0 +1,33 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam;

+

+import org.springframework.boot.SpringApplication;

+import org.springframework.boot.autoconfigure.SpringBootApplication;

+

+@SpringBootApplication

+public class OsamApplication {

+	public static void main(String[] args) {

+		SpringApplication.run(OsamApplication.class, args);

+	}

+}

diff --git a/osam-core-framework/main/src/main/resource/banner.txt b/osam-core-framework/main/src/main/resource/banner.txt
new file mode 100644
index 0000000..1ca3fcc
--- /dev/null
+++ b/osam-core-framework/main/src/main/resource/banner.txt
@@ -0,0 +1,5 @@
+ ,-----.   ,---.     ,---.   ,--.   ,--.    ,-----.  ,-----.  ,------.  ,------.

+'  .-.  ' '   .-'   /  O  \  |   `.'   |   '  .--./ '  .-.  ' |  .--. ' |  .---'

+|  | |  | `.  `-.  |  .-.  | |  |'.'|  |   |  |     |  | |  | |  '--'.' |  `--,

+'  '-'  ' .-'    | |  | |  | |  |   |  |   '  '--'\ '  '-'  ' |  |\  \  |  `---.

+ `-----'  `-----'  `--' `--' `--'   `--'    `-----'  `-----'  `--' '--' `------'

diff --git a/osam-core-framework/main/src/test/java/org/onap/osam/OsamApplicationTests.java b/osam-core-framework/main/src/test/java/org/onap/osam/OsamApplicationTests.java
new file mode 100644
index 0000000..9814086
--- /dev/null
+++ b/osam-core-framework/main/src/test/java/org/onap/osam/OsamApplicationTests.java
@@ -0,0 +1,37 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+/*package org.onap.osam;

+

+import org.junit.Test;

+import org.junit.runner.RunWith;

+import org.springframework.boot.test.context.SpringBootTest;

+import org.springframework.test.context.junit4.SpringRunner;

+

+@RunWith(SpringRunner.class)

+@SpringBootTest

+public class OsamApplicationTests {

+    @Test

+    public void contextLoads() {

+    }

+

+}*/

diff --git a/osam-core-framework/model/pom.xml b/osam-core-framework/model/pom.xml
new file mode 100644
index 0000000..2a32ecf
--- /dev/null
+++ b/osam-core-framework/model/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>model</artifactId>

+

+    <dependencies>

+        <dependency>

+            <groupId>org.springframework.boot</groupId>

+            <artifactId>spring-boot-starter-data-jpa</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>org.mariadb.jdbc</groupId>

+            <artifactId>mariadb-java-client</artifactId>

+        </dependency>

+    </dependencies>

+

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AccessPod.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AccessPod.java
new file mode 100644
index 0000000..879e937
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AccessPod.java
@@ -0,0 +1,66 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.Column;

+import javax.persistence.Entity;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class AccessPod extends BaseEntity {

+

+    @Column(unique = true)

+    private String pnfId;

+    @Column(nullable = false)

+    private String coreIp;

+    @Column(nullable = false)

+    private String corePort;

+    @Column(nullable = false)

+    private String ip;

+    @Column(nullable = false)

+    private String port;

+    private String username;

+    private String password;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("AccessPod{");

+        sb.append("pnfId='").append(pnfId).append('\'');

+        sb.append(", coreIp='").append(coreIp).append('\'');

+        sb.append(", corePort='").append(corePort).append('\'');

+        sb.append(", id=").append(id);

+        sb.append(", ip='").append(ip).append('\'');

+        sb.append(", port='").append(port).append('\'');

+        sb.append(", username='").append(username).append('\'');

+        sb.append(", password='").append(password).append('\'');

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ActiveAlarmsAndEvents.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ActiveAlarmsAndEvents.java
new file mode 100644
index 0000000..d875d08
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ActiveAlarmsAndEvents.java
@@ -0,0 +1,43 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+

+import lombok.Data;

+import lombok.NoArgsConstructor;

+

+import javax.persistence.Entity;

+import javax.persistence.Table;

+

+@Table(name = "active_alarm_and_events")

+@Entity

+@NoArgsConstructor

+public class ActiveAlarmsAndEvents extends AlarmsAndEvents {

+

+    public ActiveAlarmsAndEvents(AlarmsAndEvents alarmsAndEvents){

+        super.setAlarmName(alarmsAndEvents.getAlarmName());

+        super.setDate(alarmsAndEvents.getDate());

+        super.setId(alarmsAndEvents.getId());

+        super.setAlarmStatus(alarmsAndEvents.getAlarmStatus());

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ActivityState.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ActivityState.java
new file mode 100644
index 0000000..436f5ac
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ActivityState.java
@@ -0,0 +1,30 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public enum ActivityState {

+    ACTIVE, INACTIVE

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AdminState.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AdminState.java
new file mode 100644
index 0000000..bf92071
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AdminState.java
@@ -0,0 +1,30 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public enum AdminState {

+    ENABLED, DISABLED,PREPROVISION

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AlarmStatus.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AlarmStatus.java
new file mode 100644
index 0000000..1c6f9b0
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AlarmStatus.java
@@ -0,0 +1,34 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.AllArgsConstructor;

+import lombok.NoArgsConstructor;

+

+@AllArgsConstructor

+@NoArgsConstructor

+public enum AlarmStatus {

+    ACTIVE("active"),

+    DEACTIVE("deactive");

+    String type;

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AlarmsAndEvents.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AlarmsAndEvents.java
new file mode 100644
index 0000000..76e0f32
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/AlarmsAndEvents.java
@@ -0,0 +1,51 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.EqualsAndHashCode;

+import lombok.NoArgsConstructor;

+

+import javax.persistence.EnumType;

+import javax.persistence.Enumerated;

+import javax.persistence.MappedSuperclass;

+import javax.persistence.Temporal;

+import javax.persistence.TemporalType;

+import java.util.Date;

+

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@EqualsAndHashCode(callSuper = false)

+@MappedSuperclass

+public class AlarmsAndEvents extends BaseEntity {

+

+    @Enumerated(value = EnumType.STRING)

+    AlarmStatus alarmStatus;

+

+    String alarmName;

+

+    @Temporal(TemporalType.TIME)

+    Date date;

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/BaseEntity.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/BaseEntity.java
new file mode 100644
index 0000000..67e7fe3
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/BaseEntity.java
@@ -0,0 +1,69 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.NoArgsConstructor;

+

+import javax.persistence.GeneratedValue;

+import javax.persistence.GenerationType;

+import javax.persistence.Id;

+import javax.persistence.MappedSuperclass;

+import java.io.Serializable;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@MappedSuperclass

+@Data

+@NoArgsConstructor

+@AllArgsConstructor

+public class BaseEntity implements Serializable {

+    @Id

+    @GeneratedValue(strategy = GenerationType.IDENTITY)

+    protected Long id;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("BaseEntity{");

+        sb.append("id=").append(id);

+        sb.append('}');

+        return sb.toString();

+    }

+

+    @Override

+    public boolean equals(Object o) {

+        if (this == o) return true;

+        if (o == null || getClass() != o.getClass()) return false;

+

+        BaseEntity that = (BaseEntity) o;

+

+        return id.equals(that.id);

+    }

+

+    @Override

+    public int hashCode() {

+        return id.hashCode();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Chassis.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Chassis.java
new file mode 100644
index 0000000..0a17b3a
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Chassis.java
@@ -0,0 +1,61 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.*;

+import java.util.Set;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class Chassis extends BaseEntity {

+

+    @Column(unique = true)

+    private String clli;

+    private int rack;

+    private int shelf;

+    @Enumerated(value = EnumType.STRING)

+    private ActivityState state;

+    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "chassis")

+    private Set<OLTSlot> oltSlots;

+    @ManyToOne

+    @JoinColumn(name="accessPod_pnfId", nullable=false)

+    private AccessPod accessPod;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("Chassis{");

+        sb.append("clli=").append(clli);

+        sb.append(", state='").append(state).append('\'');

+        sb.append(", rack='").append(rack).append('\'');

+        sb.append(", shelf='").append(shelf).append('\'');

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/HistoricalAlarmsAndEvents.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/HistoricalAlarmsAndEvents.java
new file mode 100644
index 0000000..c3b7b2d
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/HistoricalAlarmsAndEvents.java
@@ -0,0 +1,38 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+

+import javax.persistence.Entity;

+import javax.persistence.Table;

+

+@Table(name = "historical_alarms_and_events")

+@Entity

+public class HistoricalAlarmsAndEvents extends AlarmsAndEvents {

+    public HistoricalAlarmsAndEvents(AlarmsAndEvents alarmsAndEvents){

+        super.setAlarmName(alarmsAndEvents.getAlarmName());

+        super.setDate(alarmsAndEvents.getDate());

+        super.setId(alarmsAndEvents.getId());

+        super.setAlarmStatus(alarmsAndEvents.getAlarmStatus());

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OLTPort.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OLTPort.java
new file mode 100644
index 0000000..4783c9d
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OLTPort.java
@@ -0,0 +1,60 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.*;

+import java.util.Set;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class OLTPort extends BaseEntity {

+

+    @Enumerated(value = EnumType.STRING)

+    private ActivityState portAuthState;

+    @Enumerated(value = EnumType.STRING)

+    private AdminState adminState;

+    private Integer portNumber;

+    @ManyToOne

+    @JoinColumn(name="OLTSlot_id", nullable=false)

+    private OLTSlot oltSlot;

+    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "OLTPort")

+    private Set<ONTDevice> ontDevices;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("oltSlot{");

+        sb.append("id=").append(id);

+        sb.append(", portAuthState='").append(portAuthState).append('\'');

+        sb.append(", adminState='").append(adminState).append('\'');

+        sb.append(", portNumber=").append(portNumber);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OLTSlot.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OLTSlot.java
new file mode 100644
index 0000000..9d39503
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OLTSlot.java
@@ -0,0 +1,80 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.*;

+import java.util.Set;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class OLTSlot extends BaseEntity {

+

+    private String serialNumber;

+    @Enumerated(value = EnumType.STRING)

+    private ActivityState operationalState;

+    @Enumerated(value = EnumType.STRING)

+    private ActivityState portAuthState;

+    @Enumerated(value = EnumType.STRING)

+    private AdminState adminState;

+    private String ipAddress;

+    private String hostname;

+    private String macAddress;

+    private Integer port;

+    private Integer number;

+    @Enumerated(value = EnumType.STRING)

+    private OltDriver oltDriver;

+    @Enumerated(value = EnumType.STRING)

+    private OltType oltType;

+    private String name;

+    @ManyToOne

+    @JoinColumn(name="chassis_id", nullable=false)

+    private Chassis chassis;

+    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "oltSlot")

+    private Set<OLTPort> oltPorts;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("oltSlot{");

+        sb.append("serialNumber=").append(serialNumber);

+        sb.append(", operationalState='").append(operationalState).append('\'');

+        sb.append(", portAuthState='").append(portAuthState).append('\'');

+        sb.append(", adminState='").append(adminState).append('\'');

+        sb.append(", ipAddress=").append(ipAddress);

+        sb.append(", hostname=").append(hostname);

+        sb.append(", macAddress=").append(macAddress);

+        sb.append(", port=").append(port);

+        sb.append(", number=").append(number);

+        sb.append(", name=").append(name);

+        sb.append(", oltDriver=").append(oltDriver);

+        sb.append(", oltType=").append(oltType);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ONTDevice.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ONTDevice.java
new file mode 100644
index 0000000..804627f
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/ONTDevice.java
@@ -0,0 +1,78 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.*;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class ONTDevice extends BaseEntity {

+

+    private String serialNumber;

+    @Enumerated(value = EnumType.STRING)

+    private ActivityState portAuthState;

+    @Enumerated(value = EnumType.STRING)

+    private AdminState adminState;

+    @Enumerated(value = EnumType.STRING)

+    private ActivityState operationalState;

+    private String ipAddress;

+    private String macAddress;

+    private int number;

+    private int sTag;

+    private int cTag;

+    private String nasPortId;

+    private String circuitId;

+    private TechnologyProfile techProfile;

+    private SpeedProfile speedProfile;

+    @ManyToOne

+    @JoinColumn(name="OLTPort_id", nullable=false)

+    private OLTPort OLTPort;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("oltSlot{");

+        sb.append("id=").append(id);

+        sb.append(", serialNumber='").append(serialNumber).append('\'');

+        sb.append(", portAuthState='").append(portAuthState).append('\'');

+        sb.append(", adminState='").append(adminState).append('\'');

+        sb.append(", operationalState='").append(operationalState).append('\'');

+        sb.append(", macAddress='").append(macAddress).append('\'');

+        sb.append(", number='").append(number).append('\'');

+        sb.append(", ipAddress=").append(ipAddress);

+        sb.append(", sTag=").append(ipAddress);

+        sb.append(", cTag=").append(cTag);

+        sb.append(", nasPortId=").append(nasPortId);

+        sb.append(", circuitId=").append(circuitId);

+        sb.append(", techProfile=").append(techProfile);

+        sb.append(", speedProfile=").append(speedProfile);

+        sb.append('}');

+        return sb.toString();

+    }

+}
\ No newline at end of file
diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OltDriver.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OltDriver.java
new file mode 100644
index 0000000..2418196
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OltDriver.java
@@ -0,0 +1,34 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public enum OltDriver {

+    OPENOLT,

+    ASFVOLT16,

+    ADTRAN,

+    TIBITS

+}

+

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OltType.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OltType.java
new file mode 100644
index 0000000..02de226
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/OltType.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public enum OltType {

+    EDGECORE,

+    ADTRAN,

+    TIBIT,

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfig.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfig.java
new file mode 100644
index 0000000..8cf9d25
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfig.java
@@ -0,0 +1,53 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.EqualsAndHashCode;

+import lombok.NoArgsConstructor;

+

+import javax.persistence.*;

+

+@Entity

+@Table(name = "pm_config")

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@EqualsAndHashCode(callSuper = false)

+public class PmConfig extends BaseEntity {

+    @Enumerated(value = EnumType.STRING)

+    private PmConfigType type;

+

+    private String name;

+    private Boolean enabled;

+    private Integer sampleFreq;

+

+    @ManyToOne

+    @JoinColumn(name="pm_configs_id")

+    private PmConfigs pmConfigs;

+

+    @ManyToOne

+    @JoinColumn(name="pm_group_config_id")

+    private PmGroupConfig pmGroupConfig;

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfigType.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfigType.java
new file mode 100644
index 0000000..ac03d48
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfigType.java
@@ -0,0 +1,30 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+public enum PmConfigType {

+    COUNTER,

+    GAUGE,

+    STATE,

+    CONTEXT

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfigs.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfigs.java
new file mode 100644
index 0000000..fa76f80
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmConfigs.java
@@ -0,0 +1,46 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.EqualsAndHashCode;

+import lombok.NoArgsConstructor;

+

+import javax.persistence.*;

+import java.util.List;

+

+@Entity

+@Table(name = "pm_configs")

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@EqualsAndHashCode(callSuper = false)

+public class PmConfigs extends BaseEntity{

+    private Boolean grouped;

+    @OneToMany(mappedBy = "pmConfigs",cascade = CascadeType.ALL, fetch = FetchType.LAZY)

+    List<PmGroupConfig> pmGroupConfig;

+    @OneToMany(mappedBy = "pmConfigs",cascade = CascadeType.ALL, fetch = FetchType.EAGER)

+    List<PmConfig> pmConfig;

+

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmGroupConfig.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmGroupConfig.java
new file mode 100644
index 0000000..a233886
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/PmGroupConfig.java
@@ -0,0 +1,50 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.EqualsAndHashCode;

+import lombok.NoArgsConstructor;

+

+import javax.persistence.*;

+import java.util.List;

+

+@Entity

+@Table(name = "pm_group_config")

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@EqualsAndHashCode(callSuper = false)

+public class PmGroupConfig extends BaseEntity {

+    private String groupName;

+    private Integer groupFreq;

+    private Boolean enabled;

+    @OneToMany(mappedBy = "pmGroupConfig",cascade = CascadeType.ALL, fetch = FetchType.EAGER)

+    private List<PmConfig> pmConfigList;

+

+    @ManyToOne

+    @JoinColumn(name="pm_configs_id")

+    private PmConfigs pmConfigs;

+

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Service.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Service.java
new file mode 100644
index 0000000..a8c5ea5
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Service.java
@@ -0,0 +1,65 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.Entity;

+import javax.persistence.FetchType;

+import javax.persistence.ManyToMany;

+import javax.persistence.OneToOne;

+import java.util.Set;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class Service extends BaseEntity {

+

+    private String name;

+    @OneToOne(fetch = FetchType.EAGER)

+    private TechnologyProfile technologyProfile;

+    @OneToOne(fetch = FetchType.EAGER)

+    private SpeedProfile upStreamProfile;

+    @OneToOne(fetch = FetchType.EAGER)

+    private SpeedProfile downStreamProfile;

+

+    @ManyToMany(mappedBy = "services")

+    private Set<Subscriber> subscribers;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("Service{");

+        sb.append("name='").append(name).append('\'');

+        sb.append(", technologyProfile=").append(technologyProfile);

+        sb.append(", id=").append(id);

+        sb.append(", upStreamProfile=").append(upStreamProfile);

+        sb.append(", downStreamProfile=").append(downStreamProfile);

+        sb.append(", subscribers=").append(subscribers);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/SpeedProfile.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/SpeedProfile.java
new file mode 100644
index 0000000..a3994da
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/SpeedProfile.java
@@ -0,0 +1,55 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.Entity;

+import javax.persistence.EnumType;

+import javax.persistence.Enumerated;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class SpeedProfile extends BaseEntity {

+

+    @Enumerated(value = EnumType.STRING)

+    private StreamDirection streamDirection;

+    private String name;

+    private String data;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("SpeedProfile{");

+        sb.append("streamDirection=").append(streamDirection);

+        sb.append(", name='").append(name).append('\'');

+        sb.append(", data='").append(data).append('\'');

+        sb.append(", id=").append(id);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/StreamDirection.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/StreamDirection.java
new file mode 100644
index 0000000..d84c518
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/StreamDirection.java
@@ -0,0 +1,30 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public enum  StreamDirection {

+    UPSTREAM, DOWNSTREAM

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Subscriber.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Subscriber.java
new file mode 100644
index 0000000..6da876d
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/Subscriber.java
@@ -0,0 +1,59 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.*;

+import java.util.Set;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@Entity

+@Setter

+@Getter

+public class Subscriber extends BaseEntity {

+

+    @Column(unique = true)

+    private String userIdentifier;

+    private Integer cTag;

+    private Integer sTag;

+    @ManyToMany

+    @JoinTable(name = "subscriber_service", joinColumns = @JoinColumn(name = "subscriber_id"),

+    inverseJoinColumns = @JoinColumn(name = "service_id"))

+    private Set<Service> services;

+

+    //TODO Configurations such as NAS and DHCP!

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("Subscriber{");

+        sb.append("userIdentifier='").append(userIdentifier).append('\'');

+        sb.append(", cTag=").append(cTag);

+        sb.append(", sTag=").append(sTag);

+        sb.append(", services=").append(services);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/TechnologyProfile.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/TechnologyProfile.java
new file mode 100644
index 0000000..e13b245
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/dao/TechnologyProfile.java
@@ -0,0 +1,50 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.dao;

+

+import lombok.Getter;

+import lombok.Setter;

+

+import javax.persistence.Entity;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+@Entity

+@Getter

+@Setter

+public class TechnologyProfile extends BaseEntity {

+

+    private String name;

+    private String data;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("TechnologyProfile{");

+        sb.append("id='").append(id).append('\'');

+        sb.append(", name=").append(name);

+        sb.append(", data=").append(data);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/AccessPodRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/AccessPodRepository.java
new file mode 100644
index 0000000..c4a400c
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/AccessPodRepository.java
@@ -0,0 +1,36 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.AccessPod;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.Optional;

+

+/**

+ * Created by cemturker on 26.09.2018.

+ */

+public interface AccessPodRepository extends CrudRepository<AccessPod, Long> {

+    Optional<AccessPod> findByPnfId(String pnfId);

+    void removeByPnfId(String pnfId);

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ActiveAlarmsAndEventsRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ActiveAlarmsAndEventsRepository.java
new file mode 100644
index 0000000..f474c5b
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ActiveAlarmsAndEventsRepository.java
@@ -0,0 +1,34 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.ActiveAlarmsAndEvents;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.Date;

+import java.util.List;

+

+public interface ActiveAlarmsAndEventsRepository extends CrudRepository<ActiveAlarmsAndEvents, Long> {

+    List<ActiveAlarmsAndEvents> findAllActiveAlarmsAndEventsByDateLessThanEqualAndDateGreaterThanEqual(Date endDate, Date startDate);

+

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ChassisRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ChassisRepository.java
new file mode 100644
index 0000000..73f1d5f
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ChassisRepository.java
@@ -0,0 +1,40 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.Chassis;

+import org.springframework.data.jpa.repository.Query;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.List;

+import java.util.Optional;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public interface ChassisRepository extends CrudRepository<Chassis, Long> {

+

+    @Query("select c from Chassis c where c.clli = ?1")

+    Optional<Chassis> findByClli(String clli);

+    Optional<List<Chassis>> findByAccessPodPnfId(String pnfId);

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/HistoricalAlarmsAndEventsRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/HistoricalAlarmsAndEventsRepository.java
new file mode 100644
index 0000000..8b1db77
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/HistoricalAlarmsAndEventsRepository.java
@@ -0,0 +1,33 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.HistoricalAlarmsAndEvents;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.Date;

+import java.util.List;

+

+public interface HistoricalAlarmsAndEventsRepository extends CrudRepository<HistoricalAlarmsAndEvents, Long> {

+    List<HistoricalAlarmsAndEvents> findAllHistoricalAlarmsAndEventsByDateLessThanEqualAndDateGreaterThanEqual(Date endDate, Date startDate);

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/OLTPortRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/OLTPortRepository.java
new file mode 100644
index 0000000..06b7694
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/OLTPortRepository.java
@@ -0,0 +1,39 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.OLTPort;

+import org.springframework.data.jpa.repository.JpaRepository;

+

+import java.util.Optional;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public interface OLTPortRepository extends JpaRepository<OLTPort, Long> {

+

+    Optional<OLTPort> findByPortNumber(int number);

+

+    Optional<OLTPort> findByPortNumberAndOltSlot_NumberAndOltSlot_ChassisClli(int portNumber, int slotNumber, String clli);

+

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/OLTSlotRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/OLTSlotRepository.java
new file mode 100644
index 0000000..d8fcddf
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/OLTSlotRepository.java
@@ -0,0 +1,37 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.OLTSlot;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.Optional;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public interface OLTSlotRepository extends CrudRepository<OLTSlot, Long> {

+

+    Optional<OLTSlot> findByNumber(int number);

+    Optional<OLTSlot> findBySerialNumber(String serialNumber);

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ONTDeviceRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ONTDeviceRepository.java
new file mode 100644
index 0000000..9aac009
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ONTDeviceRepository.java
@@ -0,0 +1,37 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.ONTDevice;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.Optional;

+

+/**

+ * Created by Zafer Kaban on 18.09.2018.

+ */

+public interface ONTDeviceRepository extends CrudRepository<ONTDevice, Long> {

+

+    Optional<ONTDevice> findBySerialNumber(String serialNumber);

+

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmConfigRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmConfigRepository.java
new file mode 100644
index 0000000..9964268
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmConfigRepository.java
@@ -0,0 +1,35 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.PmConfig;

+import org.springframework.data.repository.CrudRepository;

+

+import java.util.List;

+

+public interface PmConfigRepository extends CrudRepository<PmConfig, Long> {

+

+    List<PmConfig> getByPmConfigs_Id(Long pmConfigsId);

+

+    List<PmConfig> getByPmGroupConfig_Id(Long pmGroupConfigId);

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmConfigsRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmConfigsRepository.java
new file mode 100644
index 0000000..249f0c5
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmConfigsRepository.java
@@ -0,0 +1,29 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.PmConfigs;

+import org.springframework.data.repository.CrudRepository;

+

+public interface PmConfigsRepository extends CrudRepository<PmConfigs, Long> {

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmGroupConfigRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmGroupConfigRepository.java
new file mode 100644
index 0000000..4867afe
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/PmGroupConfigRepository.java
@@ -0,0 +1,29 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.PmGroupConfig;

+import org.springframework.data.repository.CrudRepository;

+

+public interface PmGroupConfigRepository extends CrudRepository<PmGroupConfig, Long> {

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ServiceRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ServiceRepository.java
new file mode 100644
index 0000000..fbec2a3
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/ServiceRepository.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.Service;

+import org.springframework.data.repository.CrudRepository;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public interface ServiceRepository extends CrudRepository<Service, Long> {

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/SpeedProfileRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/SpeedProfileRepository.java
new file mode 100644
index 0000000..ee4fb0e
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/SpeedProfileRepository.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.SpeedProfile;

+import org.springframework.data.repository.CrudRepository;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public interface SpeedProfileRepository extends CrudRepository<SpeedProfile, Long> {

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/SubscriberRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/SubscriberRepository.java
new file mode 100644
index 0000000..51da514
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/SubscriberRepository.java
@@ -0,0 +1,34 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.Subscriber;

+import org.springframework.data.repository.CrudRepository;

+

+/**

+ * Created by cemturker on 19.09.2018.

+ */

+public interface SubscriberRepository extends CrudRepository<Subscriber, Long> {

+    Subscriber findByUserIdentifier(String userIdentifier);

+    void deleteByUserIdentifier(String userIdentifier);

+}

diff --git a/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/TechnologyProfileRepository.java b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/TechnologyProfileRepository.java
new file mode 100644
index 0000000..302cd52
--- /dev/null
+++ b/osam-core-framework/model/src/main/java/org/onap/osam/model/repository/TechnologyProfileRepository.java
@@ -0,0 +1,32 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.model.repository;

+

+import org.onap.osam.model.dao.TechnologyProfile;

+import org.springframework.data.repository.CrudRepository;

+

+/**

+ * Created by cemturker on 18.09.2018.

+ */

+public interface TechnologyProfileRepository extends CrudRepository<TechnologyProfile, Long> {

+}

diff --git a/osam-core-framework/model/src/main/resources/application.properties b/osam-core-framework/model/src/main/resources/application.properties
new file mode 100644
index 0000000..3d2b5cb
--- /dev/null
+++ b/osam-core-framework/model/src/main/resources/application.properties
@@ -0,0 +1,10 @@
+spring.datasource.url=jdbc:mariadb://localhost:3306/osam_core

+spring.datasource.username=root

+spring.datasource.password=123456

+

+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver

+spring.jpa.hibernate.ddl-auto=update

+server.port=8888

+logging.level.org.onap.osam=DEBUG

+#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

+#logging.level.org.hibernate.type=TRACE
\ No newline at end of file
diff --git a/osam-core-framework/mvnw b/osam-core-framework/mvnw
new file mode 100644
index 0000000..7778d42
--- /dev/null
+++ b/osam-core-framework/mvnw
@@ -0,0 +1,225 @@
+#!/bin/sh

+# ----------------------------------------------------------------------------

+# Licensed to the Apache Software Foundation (ASF) under one

+# or more contributor license agreements.  See the NOTICE file

+# distributed with this work for additional information

+# regarding copyright ownership.  The ASF licenses this file

+# to you 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.

+# ----------------------------------------------------------------------------

+

+# ----------------------------------------------------------------------------

+# Maven2 Start Up Batch script

+#

+# Required ENV vars:

+# ------------------

+#   JAVA_HOME - location of a JDK home dir

+#

+# Optional ENV vars

+# -----------------

+#   M2_HOME - location of maven2's installed home dir

+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven

+#     e.g. to debug Maven itself, use

+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files

+# ----------------------------------------------------------------------------

+

+if [ -z "$MAVEN_SKIP_RC" ] ; then

+

+  if [ -f /etc/mavenrc ] ; then

+    . /etc/mavenrc

+  fi

+

+  if [ -f "$HOME/.mavenrc" ] ; then

+    . "$HOME/.mavenrc"

+  fi

+

+fi

+

+# OS specific support.  $var _must_ be set to either true or false.

+cygwin=false;

+darwin=false;

+mingw=false

+case "`uname`" in

+  CYGWIN*) cygwin=true ;;

+  MINGW*) mingw=true;;

+  Darwin*) darwin=true

+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home

+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html

+    if [ -z "$JAVA_HOME" ]; then

+      if [ -x "/usr/libexec/java_home" ]; then

+        export JAVA_HOME="`/usr/libexec/java_home`"

+      else

+        export JAVA_HOME="/Library/Java/Home"

+      fi

+    fi

+    ;;

+esac

+

+if [ -z "$JAVA_HOME" ] ; then

+  if [ -r /etc/gentoo-release ] ; then

+    JAVA_HOME=`java-config --jre-home`

+  fi

+fi

+

+if [ -z "$M2_HOME" ] ; then

+  ## resolve links - $0 may be a link to maven's home

+  PRG="$0"

+

+  # need this for relative symlinks

+  while [ -h "$PRG" ] ; do

+    ls=`ls -ld "$PRG"`

+    link=`expr "$ls" : '.*-> \(.*\)$'`

+    if expr "$link" : '/.*' > /dev/null; then

+      PRG="$link"

+    else

+      PRG="`dirname "$PRG"`/$link"

+    fi

+  done

+

+  saveddir=`pwd`

+

+  M2_HOME=`dirname "$PRG"`/..

+

+  # make it fully qualified

+  M2_HOME=`cd "$M2_HOME" && pwd`

+

+  cd "$saveddir"

+  # echo Using m2 at $M2_HOME

+fi

+

+# For Cygwin, ensure paths are in UNIX format before anything is touched

+if $cygwin ; then

+  [ -n "$M2_HOME" ] &&

+    M2_HOME=`cygpath --unix "$M2_HOME"`

+  [ -n "$JAVA_HOME" ] &&

+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`

+  [ -n "$CLASSPATH" ] &&

+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`

+fi

+

+# For Migwn, ensure paths are in UNIX format before anything is touched

+if $mingw ; then

+  [ -n "$M2_HOME" ] &&

+    M2_HOME="`(cd "$M2_HOME"; pwd)`"

+  [ -n "$JAVA_HOME" ] &&

+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"

+  # TODO classpath?

+fi

+

+if [ -z "$JAVA_HOME" ]; then

+  javaExecutable="`which javac`"

+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then

+    # readlink(1) is not available as standard on Solaris 10.

+    readLink=`which readlink`

+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then

+      if $darwin ; then

+        javaHome="`dirname \"$javaExecutable\"`"

+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"

+      else

+        javaExecutable="`readlink -f \"$javaExecutable\"`"

+      fi

+      javaHome="`dirname \"$javaExecutable\"`"

+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`

+      JAVA_HOME="$javaHome"

+      export JAVA_HOME

+    fi

+  fi

+fi

+

+if [ -z "$JAVACMD" ] ; then

+  if [ -n "$JAVA_HOME"  ] ; then

+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then

+      # IBM's JDK on AIX uses strange locations for the executables

+      JAVACMD="$JAVA_HOME/jre/sh/java"

+    else

+      JAVACMD="$JAVA_HOME/bin/java"

+    fi

+  else

+    JAVACMD="`which java`"

+  fi

+fi

+

+if [ ! -x "$JAVACMD" ] ; then

+  echo "Error: JAVA_HOME is not defined correctly." >&2

+  echo "  We cannot execute $JAVACMD" >&2

+  exit 1

+fi

+

+if [ -z "$JAVA_HOME" ] ; then

+  echo "Warning: JAVA_HOME environment variable is not set."

+fi

+

+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher

+

+# traverses directory structure from process work directory to filesystem root

+# first directory with .mvn subdirectory is considered project base directory

+find_maven_basedir() {

+

+  if [ -z "$1" ]

+  then

+    echo "Path not specified to find_maven_basedir"

+    return 1

+  fi

+

+  basedir="$1"

+  wdir="$1"

+  while [ "$wdir" != '/' ] ; do

+    if [ -d "$wdir"/.mvn ] ; then

+      basedir=$wdir

+      break

+    fi

+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)

+    if [ -d "${wdir}" ]; then

+      wdir=`cd "$wdir/.."; pwd`

+    fi

+    # end of workaround

+  done

+  echo "${basedir}"

+}

+

+# concatenates all lines of a file

+concat_lines() {

+  if [ -f "$1" ]; then

+    echo "$(tr -s '\n' ' ' < "$1")"

+  fi

+}

+

+BASE_DIR=`find_maven_basedir "$(pwd)"`

+if [ -z "$BASE_DIR" ]; then

+  exit 1;

+fi

+

+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}

+echo $MAVEN_PROJECTBASEDIR

+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"

+

+# For Cygwin, switch paths to Windows format before running java

+if $cygwin; then

+  [ -n "$M2_HOME" ] &&

+    M2_HOME=`cygpath --path --windows "$M2_HOME"`

+  [ -n "$JAVA_HOME" ] &&

+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`

+  [ -n "$CLASSPATH" ] &&

+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`

+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&

+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`

+fi

+

+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

+

+exec "$JAVACMD" \

+  $MAVEN_OPTS \

+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \

+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \

+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

diff --git a/osam-core-framework/mvnw.cmd b/osam-core-framework/mvnw.cmd
new file mode 100644
index 0000000..48c810e
--- /dev/null
+++ b/osam-core-framework/mvnw.cmd
@@ -0,0 +1,143 @@
+@REM ----------------------------------------------------------------------------

+@REM Licensed to the Apache Software Foundation (ASF) under one

+@REM or more contributor license agreements.  See the NOTICE file

+@REM distributed with this work for additional information

+@REM regarding copyright ownership.  The ASF licenses this file

+@REM to you under the Apache License, Version 2.0 (the

+@REM "License"); you may not use this file except in compliance

+@REM with the License.  You may obtain a copy of the License at

+@REM

+@REM    http://www.apache.org/licenses/LICENSE-2.0

+@REM

+@REM Unless required by applicable law or agreed to in writing,

+@REM software distributed under the License is distributed on an

+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+@REM KIND, either express or implied.  See the License for the

+@REM specific language governing permissions and limitations

+@REM under the License.

+@REM ----------------------------------------------------------------------------

+

+@REM ----------------------------------------------------------------------------

+@REM Maven2 Start Up Batch script

+@REM

+@REM Required ENV vars:

+@REM JAVA_HOME - location of a JDK home dir

+@REM

+@REM Optional ENV vars

+@REM M2_HOME - location of maven2's installed home dir

+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands

+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending

+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven

+@REM     e.g. to debug Maven itself, use

+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files

+@REM ----------------------------------------------------------------------------

+

+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'

+@echo off

+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'

+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%

+

+@REM set %HOME% to equivalent of $HOME

+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")

+

+@REM Execute a user defined script before this one

+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre

+@REM check for pre script, once with legacy .bat ending and once with .cmd ending

+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"

+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"

+:skipRcPre

+

+@setlocal

+

+set ERROR_CODE=0

+

+@REM To isolate internal variables from possible post scripts, we use another setlocal

+@setlocal

+

+@REM ==== START VALIDATION ====

+if not "%JAVA_HOME%" == "" goto OkJHome

+

+echo.

+echo Error: JAVA_HOME not found in your environment. >&2

+echo Please set the JAVA_HOME variable in your environment to match the >&2

+echo location of your Java installation. >&2

+echo.

+goto error

+

+:OkJHome

+if exist "%JAVA_HOME%\bin\java.exe" goto init

+

+echo.

+echo Error: JAVA_HOME is set to an invalid directory. >&2

+echo JAVA_HOME = "%JAVA_HOME%" >&2

+echo Please set the JAVA_HOME variable in your environment to match the >&2

+echo location of your Java installation. >&2

+echo.

+goto error

+

+@REM ==== END VALIDATION ====

+

+:init

+

+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".

+@REM Fallback to current working directory if not found.

+

+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%

+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir

+

+set EXEC_DIR=%CD%

+set WDIR=%EXEC_DIR%

+:findBaseDir

+IF EXIST "%WDIR%"\.mvn goto baseDirFound

+cd ..

+IF "%WDIR%"=="%CD%" goto baseDirNotFound

+set WDIR=%CD%

+goto findBaseDir

+

+:baseDirFound

+set MAVEN_PROJECTBASEDIR=%WDIR%

+cd "%EXEC_DIR%"

+goto endDetectBaseDir

+

+:baseDirNotFound

+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%

+cd "%EXEC_DIR%"

+

+:endDetectBaseDir

+

+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig

+

+@setlocal EnableExtensions EnableDelayedExpansion

+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a

+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%

+

+:endReadAdditionalConfig

+

+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"

+

+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"

+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

+

+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*

+if ERRORLEVEL 1 goto error

+goto end

+

+:error

+set ERROR_CODE=1

+

+:end

+@endlocal & set ERROR_CODE=%ERROR_CODE%

+

+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost

+@REM check for post script, once with legacy .bat ending and once with .cmd ending

+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"

+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"

+:skipRcPost

+

+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'

+if "%MAVEN_BATCH_PAUSE%" == "on" pause

+

+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%

+

+exit /B %ERROR_CODE%

diff --git a/osam-core-framework/pom.xml b/osam-core-framework/pom.xml
new file mode 100644
index 0000000..102e411
--- /dev/null
+++ b/osam-core-framework/pom.xml
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+	<modelVersion>4.0.0</modelVersion>

+

+	<groupId>org.onap.osam</groupId>

+	<artifactId>osam-core-framework</artifactId>

+	<version>0.0.2</version>

+	<parent>

+		<groupId>org.springframework.boot</groupId>

+		<artifactId>spring-boot-starter-parent</artifactId>

+		<version>2.0.6.RELEASE</version>

+		<relativePath/> <!-- lookup parent from repository -->

+	</parent>

+	<modules>

+		<module>common</module>

+        <module>async-jobs</module>

+		<module>model</module>

+		<module>api</module>

+		<module>external</module>

+		<module>core</module>

+		<module>web</module>

+		<module>main</module>

+	</modules>

+	<packaging>pom</packaging>

+

+	<name>osam</name>

+	<description>OpenSource Access Manager</description>

+

+	<properties>

+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

+		<java.version>1.8</java.version>

+		<grpc-spring-boot-starter.version>2.3.2</grpc-spring-boot-starter.version>

+		<os-maven-plugin.version>1.6.0</os-maven-plugin.version>

+		<protobuf-maven-plugin.version>0.5.1</protobuf-maven-plugin.version>

+		<guava.version>20.0</guava.version>

+		<msb.sdk.version>1.2.0-SNAPSHOT</msb.sdk.version>

+		<swagger.version>2.8.0</swagger.version>

+        <junitparams.version>1.1.1</junitparams.version>

+	</properties>

+

+	<dependencies>

+		<dependency>

+			<groupId>org.projectlombok</groupId>

+			<artifactId>lombok</artifactId>

+			<optional>true</optional>

+		</dependency>

+        <dependency>

+            <groupId>org.springframework.boot</groupId>

+            <artifactId>spring-boot-starter-web</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>com.google.guava</groupId>

+            <artifactId>guava</artifactId>

+            <version>${guava.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.apache.commons</groupId>

+            <artifactId>commons-lang3</artifactId>

+        </dependency>

+		<dependency>

+			<groupId>org.springframework.boot</groupId>

+			<artifactId>spring-boot-starter-test</artifactId>

+			<scope>test</scope>

+		</dependency>

+        <dependency>

+            <groupId>pl.pragmatists</groupId>

+            <artifactId>JUnitParams</artifactId>

+            <version>${junitparams.version}</version>

+            <scope>test</scope>

+        </dependency>

+	</dependencies>

+	<dependencyManagement>

+		<dependencies>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>model</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>api</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>common</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+            <dependency>

+                <groupId>${project.groupId}</groupId>

+                <artifactId>async-jobs</artifactId>

+                <version>${project.version}</version>

+            </dependency>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>external</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>core</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>web</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+			<dependency>

+				<groupId>${project.groupId}</groupId>

+				<artifactId>main</artifactId>

+				<version>${project.version}</version>

+			</dependency>

+		</dependencies>

+	</dependencyManagement>

+	<build>

+		<plugins>

+            <!-- License plugin should only run once at the start of the project.

+             For new classes, the header should be added manually by the company which creates it.-->

+            <!--<plugin>

+                <groupId>org.codehaus.mojo</groupId>

+                <artifactId>license-maven-plugin</artifactId>

+                <version>1.16</version>

+                <configuration>

+                    <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>

+                    <processStartTag>============LICENSE_START=======================================================</processStartTag>

+                    <processEndTag>============LICENSE_END=========================================================</processEndTag>

+                    <sectionDelimiter>================================================================================</sectionDelimiter>

+                    <licenseName>apache_v2</licenseName>

+                    <inceptionYear>2018</inceptionYear>

+                    <organizationName>Netsia</organizationName>

+                    <projectName>OSAM Core</projectName>

+                    <canUpdateCopyright>true</canUpdateCopyright>

+                    <canUpdateDescription>true</canUpdateDescription>

+                    <canUpdateLicense>true</canUpdateLicense>

+                    <emptyLineAfterHeader>true</emptyLineAfterHeader>

+                    <verbose>false</verbose>

+                    <includes>

+                        <include>**/*.java</include>

+                    </includes>

+                </configuration>

+                <executions>

+                    <execution>

+                        <id>first</id>

+                        <goals>

+                            <goal>update-file-header</goal>

+                        </goals>

+                        <phase>process-sources</phase>

+                    </execution>

+                </executions>

+            </plugin>-->

+			<plugin>

+				<groupId>org.springframework.boot</groupId>

+				<artifactId>spring-boot-maven-plugin</artifactId>

+				<configuration>

+					<skip>true</skip>

+				</configuration>

+			</plugin>

+		</plugins>

+        <pluginManagement>

+            <plugins>

+                <plugin>

+                    <groupId>org.apache.maven.plugins</groupId>

+                    <artifactId>maven-surefire-plugin</artifactId>

+                    <configuration>

+                        <useSystemClassLoader>false</useSystemClassLoader>

+                    </configuration>

+                </plugin>

+            </plugins>

+        </pluginManagement>

+	</build>

+</project>

diff --git a/osam-core-framework/web/pom.xml b/osam-core-framework/web/pom.xml
new file mode 100644
index 0000000..f29c599
--- /dev/null
+++ b/osam-core-framework/web/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<project xmlns="http://maven.apache.org/POM/4.0.0"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

+    <parent>

+        <artifactId>osam-core-framework</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.2</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>web</artifactId>

+    <dependencies>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>core</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+

+        <!-- For the async jobs demo controller -->

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>async-jobs</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>io.springfox</groupId>

+            <artifactId>springfox-swagger-ui</artifactId>

+            <version>${swagger.version}</version>

+            <scope>compile</scope>

+        </dependency>

+        <dependency>

+            <groupId>io.springfox</groupId>

+            <artifactId>springfox-swagger2</artifactId>

+            <version>${swagger.version}</version>

+            <scope>compile</scope>

+        </dependency>

+    </dependencies>

+

+</project>
\ No newline at end of file
diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/AbstractController.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/AbstractController.java
new file mode 100644
index 0000000..474c2c9
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/AbstractController.java
@@ -0,0 +1,56 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import org.onap.osam.common.exception.BadFormatException;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.common.exception.ServerException;

+import org.onap.osam.common.exception.UnknownTypeException;

+import org.slf4j.Logger;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+

+/**

+ * Created by cemturker on 30.09.2018.

+ */

+public abstract class AbstractController {

+

+    private Logger logger;

+

+    public AbstractController(Logger logger) {

+        this.logger = logger;

+    }

+

+    public <T>  ResponseEntity<T> proceedException(Exception e) {

+        if (e instanceof BadFormatException || e instanceof UnknownTypeException) {

+            return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();

+        } else if(e instanceof NotFoundException) {

+            return ResponseEntity.status(HttpStatus.NOT_FOUND).build();

+        } else if(e instanceof ServerException) {

+            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

+        } else {

+            logger.error("",e);

+            return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).build();

+        }

+    }

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/AccessPodRestController.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/AccessPodRestController.java
new file mode 100644
index 0000000..46b21f7
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/AccessPodRestController.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.common.dto.AccessPodDTO;

+import org.onap.osam.helper.DTOMapper;

+import org.onap.osam.model.dao.AccessPod;

+import org.onap.osam.api.service.AccessPodService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.DeleteMapping;

+import org.springframework.web.bind.annotation.GetMapping;

+import org.springframework.web.bind.annotation.PathVariable;

+import org.springframework.web.bind.annotation.PostMapping;

+import org.springframework.web.bind.annotation.RequestBody;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 27.09.2018.

+ */

+@RestController

+@RequestMapping("/accessPod")

+@Slf4j

+public class AccessPodRestController extends AbstractController {

+

+    private AccessPodService accessPodService;

+

+    @Autowired

+    public AccessPodRestController(AccessPodService accessPodService) {

+        super(log);

+        this.accessPodService = accessPodService;

+    }

+

+    @GetMapping

+    public List<AccessPodDTO> getAccessPods(){

+        return DTOMapper.covertAccessPodsToDtos(accessPodService.getAll());

+    }

+

+    @PostMapping

+    public ResponseEntity<AccessPodDTO> postAccessPod(@RequestBody AccessPodDTO accessPodDTO){

+        try {

+            log.info("Post request for {} is received",accessPodDTO);

+            AccessPod accessPod = DTOMapper.convertDtoToAccessPod(accessPodDTO);

+            accessPod = accessPodService.addOrUpdate(accessPod);

+            return new ResponseEntity<>(DTOMapper.convertAccessPodToDto(accessPod),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @DeleteMapping("pnf/{pnfId}")

+    public ResponseEntity deleteAccessPodByPnfId(@PathVariable("pnfId") String pnfId) {

+        try{

+            this.accessPodService.removeByPnfId(pnfId);

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+    @DeleteMapping("/{id}")

+    public ResponseEntity deleteAccessPod(@PathVariable("id") Long id) {

+        try {

+            this.accessPodService.removeById(id);

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+        return ResponseEntity.ok().build();

+    }

+

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/AsyncJobDemoController.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/AsyncJobDemoController.java
new file mode 100644
index 0000000..77936e5
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/AsyncJobDemoController.java
@@ -0,0 +1,74 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM

+ * ================================================================================

+ * Copyright (C) 2018 AT&T

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+package org.onap.osam.controller;

+

+import com.fasterxml.jackson.annotation.JsonAutoDetect;

+import lombok.AllArgsConstructor;

+import lombok.Getter;

+import lombok.NoArgsConstructor;

+import lombok.Setter;

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.job.AsyncJobService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.boot.jackson.JsonComponent;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.PostMapping;

+import org.springframework.web.bind.annotation.RequestBody;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+import java.util.UUID;

+

+@RestController

+@RequestMapping("/async")

+@Slf4j

+public class AsyncJobDemoController extends AbstractController{

+    private AsyncJobService asyncJobService;

+

+    @Autowired

+    public AsyncJobDemoController(AsyncJobService asyncJobService) {

+        super(log);

+        this.asyncJobService = asyncJobService;

+    }

+

+    @PostMapping("/chassis")

+    public ResponseEntity<String> createChassisWithAsyncJob(@RequestBody AsyncJobDemoControllerData data){

+        try {

+            final List<UUID> asyncJob = asyncJobService.pushBulkJob("demoUser", data.getIsRootJobSuccessful(), data.getIsRootDependantOnChildren());

+            return new ResponseEntity<String>(asyncJob.get(0).toString(), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+

+    @AllArgsConstructor

+    @NoArgsConstructor

+    @Setter

+    @Getter

+    @JsonAutoDetect

+    public static class AsyncJobDemoControllerData {

+        private Boolean isRootJobSuccessful;

+        private Boolean isRootDependantOnChildren;

+    }

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/DeviceController.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/DeviceController.java
new file mode 100644
index 0000000..f6c7aec
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/DeviceController.java
@@ -0,0 +1,166 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.api.service.DeviceService;

+import org.onap.osam.common.dto.ChassisDTO;

+import org.onap.osam.common.dto.OLTChassisDTO;

+import org.onap.osam.common.dto.ONTDTO;

+import org.onap.osam.helper.DTOMapper;

+import org.onap.osam.model.dao.*;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.*;

+

+import java.util.List;

+import java.util.Map;

+

+/**

+ * Created by Zafer Kaban on 27.09.2018.

+ */

+@CrossOrigin

+@RestController

+@RequestMapping("/device")

+@Slf4j

+public class DeviceController extends AbstractController {

+

+    private DeviceService deviceService;

+

+    @Autowired

+    public DeviceController(DeviceService deviceService) {

+        super(log);

+        this.deviceService = deviceService;

+    }

+

+    @PostMapping("/chassis")

+    public ResponseEntity<ChassisDTO> postChassis(@RequestBody ChassisDTO chassisDTO){

+        try {

+            log.info("postChassis request is received {}",chassisDTO);

+            Chassis chassis = DTOMapper.convertToChassis(chassisDTO);

+            chassis = deviceService.addChassis(chassis);

+            return new ResponseEntity<>(DTOMapper.convertChassisToDTO(chassis),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @DeleteMapping("chassis/{clli}")

+    public ResponseEntity deleteChassisByClli(@PathVariable("clli") String clli) {

+        try{

+            this.deviceService.deleteChassisByClli(clli);

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+

+    @PostMapping("/chassis/olt")

+    public ResponseEntity<OLTChassisDTO> postOLTChassis(@RequestBody OLTChassisDTO oltChassisDTO){

+        try {

+            Chassis chassis = this.deviceService.getChassisByClli(oltChassisDTO.getClli());

+            OLTSlot oltSlot = DTOMapper.convertToOLT(oltChassisDTO);

+            oltSlot.setChassis(chassis);

+            this.deviceService.addOLTSlot(oltSlot, chassis);

+            return new ResponseEntity<> (DTOMapper.convertFromOLT(oltSlot),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @PostMapping("/chassis/olt/ont-provision")

+    public ResponseEntity<ONTDTO> provisionONTDevice(@RequestBody ONTDTO ontDTO){

+        try {

+            ONTDevice ont = deviceService.provisionONTDevice(DTOMapper.convertToONTDevice(ontDTO), DeviceService.OntProvisioningType.PROVISION);

+            return new ResponseEntity<> (DTOMapper.convertFromONTDevice(ont),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @PostMapping("/chassis/olt/ont-full")

+    public ResponseEntity<ONTDTO> provisionONTDeviceFull(@RequestBody ONTDTO ontDTO){

+        try {

+            ONTDevice ont = deviceService.provisionONTDevice(DTOMapper.convertToONTDevice(ontDTO), DeviceService.OntProvisioningType.FULL);

+            return new ResponseEntity<> (DTOMapper.convertFromONTDevice(ont),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @PostMapping("/chassis/olt/ont-preprovision")

+    public ResponseEntity<ONTDTO> preprovisionONTDevice(@RequestBody ONTDTO ontDTO){

+        try {

+            ONTDevice ont = deviceService.provisionONTDevice(DTOMapper.convertToONTDevice(ontDTO), DeviceService.OntProvisioningType.PREPROVISION);

+            return new ResponseEntity<> (DTOMapper.convertFromONTDevice(ont),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @DeleteMapping("chassis/olt/ont/{ontid}")

+    public ResponseEntity deleteOntById(@PathVariable("ontid") String ontid) {

+        try{

+            this.deviceService.deleteONTDevice(new Long(ontid));

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+    @GetMapping("/chassis")

+    public ResponseEntity<List<ChassisDTO>> getAllChassis(){

+        try {

+            return new ResponseEntity<> (DTOMapper.convertChassisToDTO(deviceService.getAllChassis()), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/chassis/olt")

+    public ResponseEntity<Map<String, List<OLTChassisDTO>>> getAllOLTDevices(){

+        try {

+            return new ResponseEntity<> (DTOMapper.convertFromOLT(deviceService.getAllOLTSlots()), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/chassis/olt/ont")

+    public ResponseEntity<Map<String, List<ONTDTO>>> getAllONTDevices(){

+        try {

+            return new ResponseEntity<> (DTOMapper.convertFromONTDevice(deviceService.getAllONTDevices()), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/ServiceController.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/ServiceController.java
new file mode 100644
index 0000000..d033a1a
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/ServiceController.java
@@ -0,0 +1,135 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.model.dao.SpeedProfile;

+import org.onap.osam.model.dao.TechnologyProfile;

+import org.onap.osam.api.service.BroadBandService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.DeleteMapping;

+import org.springframework.web.bind.annotation.GetMapping;

+import org.springframework.web.bind.annotation.PathVariable;

+import org.springframework.web.bind.annotation.PostMapping;

+import org.springframework.web.bind.annotation.RequestBody;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 19.09.2018.

+ */

+@RestController

+@RequestMapping("/service")

+@Slf4j

+public class ServiceController extends AbstractController {

+

+    private BroadBandService broadBandService;

+

+    //TODOs add validations for post reqs...

+

+    @Autowired

+    public ServiceController(BroadBandService broadBandService){

+        super(log);

+        this.broadBandService = broadBandService;

+    }

+

+    @GetMapping("/speedProfile")

+    public ResponseEntity<List<SpeedProfile>> getSpeedProfiles() {

+        try{

+            return ResponseEntity.ok(this.broadBandService.getSpeedProfiles());

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/speedProfile/{id}")

+    public ResponseEntity<SpeedProfile> getSpeedProfile(@PathVariable("id") Long id) {

+        try {

+            return ResponseEntity.ok(this.broadBandService.getSpeedProfile(id));

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @DeleteMapping("/speedProfile/{id}")

+    public ResponseEntity deleteSpeedProfile(@PathVariable("id") Long id) {

+        try {

+            this.broadBandService.removeSpeedProfile(id);

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @PostMapping("/speedProfile")

+    public ResponseEntity<SpeedProfile> createSpeedProfile(@RequestBody SpeedProfile speedProfile) {

+        try {

+            return new ResponseEntity<>(this.broadBandService.addSpeedProfile(speedProfile),

+                    HttpStatus.CREATED);

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+    @GetMapping("/technologyProfile")

+    public ResponseEntity<List<TechnologyProfile>> getTechnologyProfiles() {

+        try {

+            return ResponseEntity.ok(this.broadBandService.getTechnologyProfiles());

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/technologyProfile/{id}")

+    public ResponseEntity<TechnologyProfile> getTechnologyProfile(@PathVariable("id") Long id) {

+        try {

+            return ResponseEntity.ok(this.broadBandService.getTechnologyProfile(id));

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @DeleteMapping("/technologyProfile/{id}")

+    public ResponseEntity deleteTechnologyProfile(@PathVariable("id") Long id) {

+        try {

+            this.broadBandService.removeSpeedProfile(id);

+            return ResponseEntity.ok().build();

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @PostMapping("/technologyProfile")

+    public ResponseEntity<TechnologyProfile> createTechnologyProfile(@RequestBody TechnologyProfile technologyProfile) {

+        try {

+            return new ResponseEntity<>(this.broadBandService.addTechnologyProfile(technologyProfile),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/TopologyController.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/TopologyController.java
new file mode 100644
index 0000000..18ea729
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/TopologyController.java
@@ -0,0 +1,70 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.api.service.AccessPodService;

+import org.onap.osam.api.service.DeviceService;

+import org.onap.osam.common.dto.AccessPodDTO;

+import org.onap.osam.helper.DTOMapper;

+import org.onap.osam.model.dao.AccessPod;

+import org.onap.osam.model.dao.Chassis;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.GetMapping;

+import org.springframework.web.bind.annotation.PathVariable;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 03.10.2018.

+ */

+@RestController

+@RequestMapping("topology")

+@Slf4j

+public class TopologyController extends AbstractController {

+    private AccessPodService accessPodService;

+    private DeviceService deviceService;

+

+    @Autowired

+    public TopologyController(AccessPodService accessPodService,

+                              DeviceService deviceService) {

+        super(log);

+        this.accessPodService = accessPodService;

+        this.deviceService = deviceService;

+    }

+

+    @GetMapping("/accessPod/{pnfId}")

+    public ResponseEntity<AccessPodDTO> getTopologyWithPnfId(@PathVariable("pnfId") String pnfId) {

+        try{

+            log.info("GetTopology with pnfId:{} is received.",pnfId);

+            AccessPod accessPod = accessPodService.findByPnfId(pnfId);

+            List<Chassis> chassisList = deviceService.getByPnfId(pnfId);

+            return ResponseEntity.ok(DTOMapper.representTheAccessPod(chassisList,accessPod));

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/controller/config/SwaggerConfig.java b/osam-core-framework/web/src/main/java/org/onap/osam/controller/config/SwaggerConfig.java
new file mode 100644
index 0000000..20a538c
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/controller/config/SwaggerConfig.java
@@ -0,0 +1,57 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller.config;

+

+import org.springframework.context.annotation.Bean;

+import org.springframework.context.annotation.Configuration;

+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

+import springfox.documentation.builders.PathSelectors;

+import springfox.documentation.builders.RequestHandlerSelectors;

+import springfox.documentation.spi.DocumentationType;

+import springfox.documentation.spring.web.plugins.Docket;

+import springfox.documentation.swagger2.annotations.EnableSwagger2;

+

+/**

+ * Created by cemturker on 04.10.2018.

+ */

+@Configuration

+@EnableSwagger2

+public class SwaggerConfig extends WebMvcConfigurationSupport {

+    @Bean

+    public Docket osamApi() {

+        return new Docket(DocumentationType.SWAGGER_2)

+                .select()                 .apis(RequestHandlerSelectors.any())

+                .paths(PathSelectors.any())

+                .build();

+    }

+

+    @Override

+    protected void addResourceHandlers(ResourceHandlerRegistry registry) {

+        registry.addResourceHandler("swagger-ui.html")

+                .addResourceLocations("classpath:/META-INF/resources/");

+

+        registry.addResourceHandler("/webjars/**")

+                .addResourceLocations("classpath:/META-INF/resources/webjars/");

+    }

+}

diff --git a/osam-core-framework/web/src/main/java/org/onap/osam/helper/DTOMapper.java b/osam-core-framework/web/src/main/java/org/onap/osam/helper/DTOMapper.java
new file mode 100644
index 0000000..8a941ee
--- /dev/null
+++ b/osam-core-framework/web/src/main/java/org/onap/osam/helper/DTOMapper.java
@@ -0,0 +1,249 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.helper;

+

+import com.google.common.collect.Lists;

+import org.onap.osam.common.dto.AccessPodDTO;

+import org.onap.osam.common.dto.ChassisDTO;

+import org.onap.osam.common.dto.OLTChassisDTO;

+import org.onap.osam.common.dto.OLTPortDTO;

+import org.onap.osam.common.dto.ONTDTO;

+import org.onap.osam.model.dao.*;

+

+import java.util.ArrayList;

+import java.util.List;

+import java.util.Map;

+import java.util.stream.Collectors;

+

+

+public final class DTOMapper {

+

+    private DTOMapper () {

+

+    }

+

+    public static Chassis convertToChassis (ChassisDTO chassisDTO) {

+        Chassis chassis = new Chassis();

+        chassis.setClli(chassisDTO.getClli());

+        chassis.setShelf(chassisDTO.getShelf());

+        chassis.setRack(chassisDTO.getRack());

+        chassis.setState(ActivityState.ACTIVE);

+        AccessPod accessPod = new AccessPod();

+        accessPod.setPnfId(chassisDTO.getPnfId());

+        chassis.setAccessPod(accessPod);

+        return chassis;

+    }

+

+

+

+

+    public static OLTSlot convertToOLT (OLTChassisDTO oltChassisDTO) {

+        OLTSlot oltSlot = new OLTSlot();

+        oltSlot.setIpAddress(oltChassisDTO.getIpAddress());

+        oltSlot.setPort(oltChassisDTO.getPortNumber());

+        oltSlot.setName(oltChassisDTO.getName());

+        oltSlot.setOltDriver(OltDriver.valueOf(oltChassisDTO.getOltDriver()));

+        oltSlot.setOltType(OltType.valueOf(oltChassisDTO.getOltType()));

+        return oltSlot;

+    }

+

+    public static ChassisDTO convertChassisToDTO(Chassis chassis) {

+        ChassisDTO chassisDTO = new ChassisDTO();

+        chassisDTO.setId(chassis.getId());

+        chassisDTO.setClli(chassis.getClli());

+        chassisDTO.setRack(chassis.getRack());

+        chassisDTO.setShelf(chassis.getShelf());

+        chassisDTO.setPnfId(chassis.getAccessPod().getPnfId());

+        return chassisDTO;

+    }

+

+    public static List<ChassisDTO> convertChassisToDTO(List<Chassis> chassises) {

+        return chassises.stream().map(x -> convertChassisToDTO(x)).collect(Collectors.toList());

+    }

+

+    public static Map<String, List<OLTChassisDTO>> convertFromOLT(List<OLTSlot> oltSlots){

+        return oltSlots.stream().map(x -> convertFromOLT(x)).collect(Collectors.toList()).stream().collect(Collectors.groupingBy(OLTChassisDTO::getClli));

+    }

+

+    public static OLTChassisDTO convertFromOLT (OLTSlot oltSlot) {

+        OLTChassisDTO oltChassisDTO = new OLTChassisDTO();

+        oltChassisDTO.setClli(oltSlot.getChassis().getClli());

+        oltChassisDTO.setIpAddress(oltSlot.getIpAddress());

+        oltChassisDTO.setName(oltSlot.getName());

+        oltChassisDTO.setOltDriver(oltSlot.getOltDriver().name());

+        oltChassisDTO.setOltType(oltSlot.getOltType().name());

+        oltChassisDTO.setPortNumber(oltSlot.getPort());

+        oltChassisDTO.setId(oltSlot.getId());

+        return oltChassisDTO;

+    }

+

+    public static ONTDTO convertFromONTDevice (ONTDevice ontDevice) {

+        ONTDTO ontdto = new ONTDTO();

+        ontdto.setSerialNumber(ontDevice.getSerialNumber());

+        ontdto.setPortNumber(ontDevice.getOLTPort().getPortNumber());

+        ontdto.setId(ontDevice.getId());

+        ontdto.setSlotNumber(ontDevice.getOLTPort().getOltSlot().getNumber());

+        ontdto.setClli(ontDevice.getOLTPort().getOltSlot().getChassis().getClli());

+        ontdto.setCtag(ontDevice.getCTag());

+        ontdto.setStag(ontDevice.getSTag());

+        ontdto.setCircuitId(ontDevice.getCircuitId());

+        ontdto.setNasPortId(ontDevice.getNasPortId());

+        if (ontDevice.getTechProfile() != null) {

+            ontdto.setTechnologyProfile(ontDevice.getTechProfile().getName());

+        }

+        if (ontDevice.getSpeedProfile() != null) {

+            ontdto.setSpeedProfile(ontDevice.getSpeedProfile().getName());

+        }

+        return ontdto;

+    }

+

+    public static ONTDevice convertToONTDevice (ONTDTO ontdto) {

+        ONTDevice ontDevice = new ONTDevice();

+        ontDevice.setNumber(ontdto.getOntNumber());

+        ontDevice.setSerialNumber(ontdto.getSerialNumber());

+        ontDevice.setCTag(ontdto.getCtag());

+        ontDevice.setSTag(ontdto.getStag());

+        ontDevice.setCircuitId(ontdto.getCircuitId());

+        ontDevice.setNasPortId(ontdto.getNasPortId());

+        TechnologyProfile technologyProfile = new TechnologyProfile();

+        technologyProfile.setName(ontdto.getTechnologyProfile());

+        ontDevice.setTechProfile(technologyProfile);

+        SpeedProfile speedProfile = new SpeedProfile();

+        speedProfile.setName(ontdto.getSpeedProfile());

+        ontDevice.setSpeedProfile(speedProfile);

+        Chassis chassis = new Chassis();

+        chassis.setClli(ontdto.getClli());

+        OLTSlot oltSlot = new OLTSlot();

+        oltSlot.setChassis(chassis);

+        OLTPort oltPort = new OLTPort();

+        oltPort.setPortNumber(ontdto.getPortNumber());

+        oltPort.setOltSlot(oltSlot);

+        ontDevice.setOLTPort(oltPort);

+        return ontDevice;

+    }

+

+    public static Map<String, List<ONTDTO>> convertFromONTDevice(List<ONTDevice> ontDevices){

+        return ontDevices.stream().map(x -> convertFromONTDevice(x)).collect(Collectors.toList()).stream().collect(Collectors.groupingBy(ONTDTO::getClli));

+    }

+

+    public static AccessPod convertDtoToAccessPod(AccessPodDTO dto) {

+        //TODO validate..

+        AccessPod accessPod = new AccessPod();

+        accessPod.setPnfId(dto.getPnfId());

+        accessPod.setId(dto.getId());

+        accessPod.setCoreIp(dto.getCoreIp());

+        accessPod.setCorePort(dto.getCorePort());

+        accessPod.setUsername(dto.getUsername());

+        accessPod.setPassword(dto.getPassword());

+        accessPod.setIp(dto.getIp());

+        accessPod.setPort(dto.getPort());

+        return accessPod;

+    }

+

+    public static AccessPodDTO convertAccessPodToDto(AccessPod accessPod) {

+        //TODO validate..

+        AccessPodDTO dto = new AccessPodDTO();

+        dto.setPnfId(accessPod.getPnfId());

+        dto.setCoreIp(accessPod.getCoreIp());

+        dto.setCorePort(accessPod.getCorePort());

+        dto.setUsername(accessPod.getUsername());

+        dto.setPassword(accessPod.getPassword());

+        dto.setIp(accessPod.getIp());

+        dto.setId(accessPod.getId());

+        dto.setPort(accessPod.getPort());

+        return dto;

+    }

+

+    private static OLTPortDTO convertOLTPortToDTO(OLTPort oltPort) {

+        OLTPortDTO oltPortDTO = new OLTPortDTO();

+        oltPortDTO.setId(oltPort.getId());

+        oltPortDTO.setAdminState(oltPort.getAdminState().name());

+        oltPortDTO.setPortAuthState(oltPort.getPortAuthState().name());

+        oltPortDTO.setPortNumber(oltPort.getPortNumber());

+        return oltPortDTO;

+    }

+

+    public static List<AccessPodDTO> covertAccessPodsToDtos(List<AccessPod> accessPodList) {

+        //TODO validate..

+        List<AccessPodDTO> dtos = new ArrayList<>();

+        for (AccessPod accessPod : accessPodList) {

+            dtos.add(convertAccessPodToDto(accessPod));

+        }

+        return dtos;

+    }

+

+    public static AccessPodDTO representTheAccessPod(List<Chassis> chassisList, AccessPod accessPod) {

+        if (accessPod == null) {

+            return null;

+        }

+        AccessPodDTO accessPodDTO = convertAccessPodToDto(accessPod);

+        if (chassisList == null || chassisList.isEmpty()) {

+            return accessPodDTO;

+        }

+        List<ChassisDTO> chassisDTOS = new ArrayList<>();

+        accessPodDTO.setChassises(chassisDTOS);

+        for (Chassis chassis : chassisList) {

+            chassisDTOS.add(representTheChassis(chassis));

+        }

+        return accessPodDTO;

+    }

+

+    public static ChassisDTO representTheChassis(Chassis chassis) {

+        ChassisDTO chassisDTO = convertChassisToDTO(chassis);

+        if (chassis.getOltSlots() == null || chassis.getOltSlots().isEmpty()) {

+            return chassisDTO;

+        }

+        List<OLTChassisDTO> oltChassisDTOS = Lists.newArrayList();

+        chassisDTO.setOlts(oltChassisDTOS);

+        for (OLTSlot oltSlot : chassis.getOltSlots()) {

+            oltChassisDTOS.add(representTheOLTSlot(oltSlot));

+        }

+        return chassisDTO;

+    }

+

+    public static OLTChassisDTO representTheOLTSlot(OLTSlot oltSlot) {

+        OLTChassisDTO oltChassisDTO = convertFromOLT(oltSlot);

+        if (oltSlot.getOltPorts() == null || oltSlot.getOltPorts().isEmpty()) {

+            return oltChassisDTO;

+        }

+        List<OLTPortDTO> oltPortDTOS = Lists.newArrayList();

+        oltChassisDTO.setOltPorts(oltPortDTOS);

+        for (OLTPort oltPort : oltSlot.getOltPorts()) {

+            oltPortDTOS.add(representTheOLTPort(oltPort));

+        }

+        return oltChassisDTO;

+    }

+

+    public static OLTPortDTO representTheOLTPort(OLTPort oltPort) {

+        OLTPortDTO portDTO = convertOLTPortToDTO(oltPort);

+        if (oltPort.getOntDevices() == null || oltPort.getOntDevices().isEmpty()) {

+            return portDTO;

+        }

+        List<ONTDTO> ontdtos = Lists.newArrayList();

+        portDTO.setOntDevices(ontdtos);

+        for (ONTDevice ontDevice : oltPort.getOntDevices()) {

+            ontdtos.add(convertFromONTDevice(ontDevice));

+        }

+        return portDTO;

+    }

+}