OSAM infra seed code - merge with osam-core side-by-side - fixed warnings in onap-enabler POMs
Change-Id: I0cd9ea39d4b7c1dc088ab0ecd6fb787c7f490e5e
Signed-off-by: Aharoni, Pavel (pa0916) <pavel.aharoni@intl.att.com>
diff --git a/osam-core/core/pom.xml b/osam-core/core/pom.xml
new file mode 100644
index 0000000..1db7193
--- /dev/null
+++ b/osam-core/core/pom.xml
@@ -0,0 +1,39 @@
+<?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</artifactId>
+ <groupId>org.onap.osam</groupId>
+ <version>0.0.1-SNAPSHOT</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>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/osam-core/core/src/main/java/org/onap/osam/core/AbstractBaseServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/AbstractBaseServiceImpl.java
new file mode 100644
index 0000000..ef69df9
--- /dev/null
+++ b/osam-core/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/core/src/main/java/org/onap/osam/core/AccessPodServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/AccessPodServiceImpl.java
new file mode 100644
index 0000000..b3e00c5
--- /dev/null
+++ b/osam-core/core/src/main/java/org/onap/osam/core/AccessPodServiceImpl.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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) {
+ PNF pnf = aaiClient.queryPnf(value.getPnfId());
+ Optional<AccessPod> accessPodOptional = accessPodRepository.findByPnfId(pnf.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()) {
+ throw new NotFoundException("pnfId:"+pnfId+ " is not found");
+ }
+ return accessPodOp.get();
+ }
+
+ @Override
+ public void removeByPnfId(String pnfId) {
+ accessPodRepository.removeByPnfId(pnfId);
+ }
+}
diff --git a/osam-core/core/src/main/java/org/onap/osam/core/AlarmServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/AlarmServiceImpl.java
new file mode 100644
index 0000000..57aa5f1
--- /dev/null
+++ b/osam-core/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/core/src/main/java/org/onap/osam/core/BroadBandServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/BroadBandServiceImpl.java
new file mode 100644
index 0000000..fa0fdbc
--- /dev/null
+++ b/osam-core/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/core/src/main/java/org/onap/osam/core/DeviceServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/DeviceServiceImpl.java
new file mode 100644
index 0000000..610e217
--- /dev/null
+++ b/osam-core/core/src/main/java/org/onap/osam/core/DeviceServiceImpl.java
@@ -0,0 +1,274 @@
+/*-
+ * ============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.InvalidOperationException;
+import org.onap.osam.common.exception.NotFoundException;
+import org.onap.osam.api.service.DeviceService;
+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);
+ String deviceId = abstractOLTClient.createChassis(chassis);
+ if (deviceId != null) {
+ return add(chassis, chassisRepository);
+ }
+ return null;
+ }
+
+ @Override
+ public void deleteChassis(Long 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();
+ remove(id, chassisRepository,Chassis.class);
+ }
+ }
+
+ @Override
+ public Chassis getChassisById(Long id) {
+ Optional<Chassis> chassis = chassisRepository.findById(id);
+ if (chassis.isPresent()) {
+ return chassis.get();
+ }
+ return null;
+ }
+
+ @Override
+ public Chassis getChassisByClli(String clli) {
+ Optional<Chassis> chassis = chassisRepository.findByClli(clli);
+ if (chassis.isPresent()) {
+ return chassis.get();
+ }
+ return null;
+ }
+
+ @Override
+ public Long getChassisCount() {
+ return chassisRepository.count();
+ }
+
+ @Override
+ public List<Chassis> getByPnfId(String pnfId) {
+ Optional<List<Chassis>> chassisList = chassisRepository.findByAccessPodPnfId(pnfId);
+ if (!chassisList.isPresent()) {
+ 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 = chassis.getOltSlots();
+ int size = oltSlots.size();
+ if (size == 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);
+ String deviceId = abstractOLTClient.createOLTChassis(oltSlot);
+ if (deviceId != null) {
+ oltSlot.setChassis(chassis);
+ 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);
+ add(oltPort, oltPortRepository);
+ }
+ if (oltSlots.isEmpty()) {
+ oltSlots = new HashSet<>();
+ }
+ oltSlots.add(oltSlot);
+ chassis.setOltSlots(oltSlots);
+ chassisRepository.save(chassis);
+ }
+ return oltSlot;
+ }
+
+ @Override
+ public void deleteOLTSlot(Long id) {
+ oltSlotRepository.deleteById(id);
+ }
+
+ @Override
+ public OLTSlot getOLTSlotById(Long id) {
+ Optional<OLTSlot> oltSlot = oltSlotRepository.findById(id);
+ if (oltSlot.isPresent()) {
+ return oltSlot.get();
+ }
+ return null;
+ }
+
+ @Override
+ public OLTSlot getOLTSlotBySerialNumber(String serialNumber) {
+ Optional<OLTSlot> oltSlot = oltSlotRepository.findBySerialNumber(serialNumber);
+ if (oltSlot.isPresent()) {
+ return oltSlot.get();
+ }
+ return null;
+ }
+
+ @Override
+ public List<OLTSlot> getAllOLTSlots() {
+ return Lists.newArrayList(oltSlotRepository.findAll());
+ }
+
+ @Override
+ public void deleteOLTPort(Long id) {
+ oltPortRepository.deleteById(id);
+ }
+
+ @Override
+ public OLTPort getOLTPortById(Long id) {
+ Optional<OLTPort> oltPort = oltPortRepository.findById(id);
+ if (oltPort.isPresent()) {
+ return oltPort.get();
+ }
+ return null;
+ }
+
+ @Override
+ public ONTDevice addONTDevice(String clli, int slotNumber, int portNumber, String serialNumber){
+ ONTDevice ont = null;
+ Optional<OLTPort> thePort = oltPortRepository.findByPortNumberAndOltSlot_NumberAndOltSlot_ChassisClli(portNumber,slotNumber,clli);
+ if (thePort.isPresent()) {
+ OLTPort port = thePort.get();
+ log.info("Port found : {}", thePort);
+ Set<ONTDevice> ontDevices = port.getOntDevices();
+ int size = ontDevices.size();
+ if (size == NUMBER_OF_ONT_DEVICES) {
+ throw new InvalidOperationException("Maximum number of ONTs exceeded");
+ }
+ int ontNumber = size+1;
+ boolean result = abstractOLTClient.provisionONT(clli, slotNumber, portNumber,ontNumber,serialNumber);
+ if (result){
+ ont = new ONTDevice();
+ ont.setSerialNumber(serialNumber);
+ ont.setNumber(ontNumber);
+ ont.setOLTPort(port);
+ ont.setAdminState(AdminState.ENABLED);
+ ont.setOperationalState(ActivityState.ACTIVE);
+ ont.setPortAuthState(ActivityState.ACTIVE);
+ add(ont,ontDeviceRepository);
+ ontDevices.add(ont);
+ oltPortRepository.save(port);
+ } else {
+ log.error("Error rpc failed");
+ throw new NotFoundException("Operation failed");
+ }
+ } else {
+ log.error("Port not found");
+ throw new NotFoundException("Operation failed");
+ }
+ return ont;
+ }
+
+ @Override
+ public void deleteONTDevice(Long id) {
+ ontDeviceRepository.deleteById(id);
+ }
+
+ @Override
+ public ONTDevice getONTDeviceById(Long id) {
+ Optional<ONTDevice> ontDevice = ontDeviceRepository.findById(id);
+ if (ontDevice.isPresent()) {
+ ontDevice.get();
+ }
+ return null;
+ }
+
+ @Override
+ public ONTDevice getONTDeviceBySerialNumber(String serialNumber) {
+ Optional<ONTDevice> ontDevice = ontDeviceRepository.findBySerialNumber(serialNumber);
+ if (ontDevice.isPresent()) {
+ ontDevice.get();
+ }
+ return null;
+ }
+
+ @Override
+ public List<ONTDevice> getAllONTDevices() {
+ return Lists.newArrayList(ontDeviceRepository.findAll());
+ }
+}
diff --git a/osam-core/core/src/main/java/org/onap/osam/core/PmConfigsServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/PmConfigsServiceImpl.java
new file mode 100644
index 0000000..b1e3f29
--- /dev/null
+++ b/osam-core/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/core/src/main/java/org/onap/osam/core/SubscriberServiceImpl.java b/osam-core/core/src/main/java/org/onap/osam/core/SubscriberServiceImpl.java
new file mode 100644
index 0000000..e295655
--- /dev/null
+++ b/osam-core/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);
+ }
+}