initial commit
diff --git a/src/main/java/org.onosproject.xran/wrapper/CellMap.java b/src/main/java/org.onosproject.xran/wrapper/CellMap.java
new file mode 100644
index 0000000..ea4fc77
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/CellMap.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import io.netty.channel.ChannelHandlerContext;
+import org.onosproject.net.DeviceId;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PCIARFCN;
+import org.onosproject.xran.entities.RnibCell;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public class CellMap {
+    private ConcurrentMap<ECGI, ChannelHandlerContext> ecgiCtx = new ConcurrentHashMap<>();
+
+    private BiMap<PCIARFCN, ECGI> pciarfcnMap = HashBiMap.create();
+    private XranStore xranStore;
+
+    public CellMap(XranStore xranStore) {
+        this.xranStore = xranStore;
+    }
+
+    public void putPciArfcn(RnibCell value) {
+        PCIARFCN pciarfcn = new PCIARFCN();
+        pciarfcn.setPci(value.getConf().getPci());
+        pciarfcn.setEarfcnDl(value.getConf().getEarfcnDl());
+        pciarfcnMap.put(pciarfcn, value.getEcgi());
+    }
+
+    public void put(RnibCell value, ChannelHandlerContext ctx) {
+        if (value.getEcgi() != null) {
+            ecgiCtx.put(value.getEcgi(), ctx);
+            xranStore.storeCell(value);
+        }
+    }
+
+    public RnibCell get(PCIARFCN id) {
+        ECGI ecgi = null;
+        ecgi = pciarfcnMap.get(id);
+
+        if (ecgi != null) {
+            return xranStore.getCell(ecgi);
+        }
+        return null;
+    }
+
+    public RnibCell get(ECGI ecgi) {
+        if (ecgi != null) {
+            return xranStore.getCell(ecgi);
+        }
+        return null;
+    }
+
+    public boolean remove(Object key) {
+        ECGI ecgi = null;
+        if (key instanceof ECGI) {
+            ecgi = (ECGI) key;
+        } else if (key instanceof PCIARFCN) {
+            ecgi = pciarfcnMap.get(key);
+        }
+
+        if (ecgi != null) {
+            pciarfcnMap.inverse().remove(ecgi);
+            ecgiCtx.remove(ecgi);
+        }
+
+        return ecgi != null && xranStore.removeCell(ecgi);
+    }
+
+    public ChannelHandlerContext getCtx(ECGI id) {
+        return ecgiCtx.get(id);
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/wrapper/LinkMap.java b/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
new file mode 100644
index 0000000..827781f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
+
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibLink;
+import org.onosproject.xran.entities.RnibUe;
+import org.onosproject.xran.identifiers.LinkId;
+import org.slf4j.Logger;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+public class LinkMap {
+    private static final Logger log = getLogger(LinkMap.class);
+
+    private ConcurrentMap<CRNTI, MMEUES1APID> crntiMme = new ConcurrentHashMap<>();
+
+    private XranStore xranStore;
+
+    public LinkMap(XranStore xranStore) {
+        this.xranStore = xranStore;
+    }
+
+    public void putPrimaryLink(RnibCell cell, RnibUe ue) {
+        RnibLink link = new RnibLink();
+        link.setLinkId(cell, ue);
+        link.setType(RnibLink.Type.SERVING_PRIMARY);
+        xranStore.getLinksByUeId(ue.getMmeS1apId().longValue())
+                .forEach(l -> l.setType(RnibLink.Type.SERVING_SECONDARY));
+        xranStore.storeLink(link);
+        crntiMme.put(ue.getRanId(), ue.getMmeS1apId());
+    }
+
+    public RnibLink putNonServingLink(RnibCell cell, CRNTI crnti) {
+        RnibLink link = null;
+        MMEUES1APID mmeues1APID = crntiMme.get(crnti);
+
+        if (mmeues1APID != null) {
+            link = new RnibLink();
+            RnibUe ue = xranStore.getUe(mmeues1APID);
+            link.setLinkId(cell, ue);
+            link.setType(RnibLink.Type.NON_SERVING);
+            xranStore.storeLink(link);
+        } else {
+            log.error("Could not find mapping for CRNTI to UE. Aborting creation of non-serving link");
+        }
+        return link;
+    }
+
+    public RnibLink get(ECGI src, MMEUES1APID dst) {
+        if (src != null && dst != null) {
+            return xranStore.getLink(src, dst);
+        }
+        return null;
+    }
+
+    public RnibLink get(ECGI src, CRNTI dst) {
+        MMEUES1APID mmeues1APID = crntiMme.get(dst);
+
+        if (mmeues1APID != null) {
+            return xranStore.getLink(src, mmeues1APID);
+        }
+        return null;
+    }
+
+    public boolean remove(ECGI src, MMEUES1APID dst) {
+        RnibLink link = xranStore.getLink(src, dst);
+
+        if (link != null) {
+            LinkId linkId = link.getLinkId();
+            if (linkId != null) {
+                return xranStore.removeLink(linkId);
+            }
+        }
+        return false;
+    }
+
+    public boolean remove(ECGI src, CRNTI dst) {
+        MMEUES1APID mmeues1APID = crntiMme.get(dst);
+
+        RnibLink link = xranStore.getLink(src, mmeues1APID);
+        if (link != null) {
+            LinkId linkId = link.getLinkId();
+            if (linkId != null) {
+                return xranStore.removeLink(linkId);
+            }
+        }
+        return false;
+    }
+
+    public ECGI getPrimaryCell(RnibUe ue) {
+        List<RnibLink> linksByUeId = xranStore.getLinksByUeId(ue.getMmeS1apId().longValue());
+        Optional<RnibLink> primary = linksByUeId.stream().filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY)).findFirst();
+
+        if (primary.isPresent()) {
+            return primary.get().getLinkId().getSource();
+        }
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/wrapper/UeMap.java b/src/main/java/org.onosproject.xran/wrapper/UeMap.java
new file mode 100644
index 0000000..a42ecbd
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/UeMap.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import io.netty.channel.ChannelHandlerContext;
+import org.onosproject.net.HostId;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ENBUES1APID;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.entities.RnibUe;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public class UeMap {
+    private BiMap<CRNTI, MMEUES1APID> crntUe = HashBiMap.create();
+
+    private XranStore xranStore;
+
+    public UeMap(XranStore xranStore) {
+        this.xranStore = xranStore;
+    }
+
+    public void put(RnibUe ue) {
+
+        MMEUES1APID mmeS1apId = ue.getMmeS1apId();
+        if (mmeS1apId != null) {
+            xranStore.storeUe(ue);
+        }
+
+        CRNTI ranId = ue.getRanId();
+        if (ranId != null) {
+            crntUe.put(ranId, ue.getMmeS1apId());
+        }
+    }
+
+    public RnibUe get(CRNTI id) {
+        MMEUES1APID mme = crntUe.get(id);
+        if (mme != null) {
+            return xranStore.getUe(mme);
+        }
+        return null;
+    }
+
+    public RnibUe get(MMEUES1APID mme) {
+        if (mme != null) {
+            return xranStore.getUe(mme);
+        }
+        return null;
+    }
+
+    public boolean remove(MMEUES1APID id) {
+        crntUe.inverse().remove(id);
+        return xranStore.removeUe(id);
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/wrapper/package-info.java b/src/main/java/org.onosproject.xran/wrapper/package-info.java
new file mode 100644
index 0000000..c724c32
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
\ No newline at end of file