This repository has been archived by the owner on Dec 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now it creates a local collection that stores the last article processed
- Loading branch information
Showing
7 changed files
with
249 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
....nntp/src/org/eclipse/scava/platform/communicationchannel/nntp/model/NntpDataManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Edge Hill University | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
package org.eclipse.scava.platform.communicationchannel.nntp.model; | ||
|
||
import com.googlecode.pongo.runtime.*; | ||
import com.mongodb.*; | ||
// protected region custom-imports on begin | ||
// protected region custom-imports end | ||
|
||
public class NntpDataManager extends PongoDB { | ||
|
||
public NntpDataManager() {} | ||
|
||
public NntpDataManager(DB db) { | ||
setDb(db); | ||
} | ||
|
||
protected NntpDatumCollection nntpData = null; | ||
|
||
// protected region custom-fields-and-methods on begin | ||
// protected region custom-fields-and-methods end | ||
|
||
|
||
public NntpDatumCollection getNntpData() { | ||
return nntpData; | ||
} | ||
|
||
|
||
@Override | ||
public void setDb(DB db) { | ||
super.setDb(db); | ||
nntpData = new NntpDatumCollection(db.getCollection("NntpDataManager.nntpData")); | ||
pongoCollections.add(nntpData); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...hannel.nntp/src/org/eclipse/scava/platform/communicationchannel/nntp/model/NntpDatum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Edge Hill University | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
package org.eclipse.scava.platform.communicationchannel.nntp.model; | ||
|
||
import com.googlecode.pongo.runtime.Pongo; | ||
import com.googlecode.pongo.runtime.querying.NumericalQueryProducer; | ||
import com.googlecode.pongo.runtime.querying.StringQueryProducer; | ||
|
||
|
||
public class NntpDatum extends Pongo { | ||
|
||
|
||
|
||
public NntpDatum() { | ||
super(); | ||
OSSMERTERID.setOwningType("org.eclipse.scava.platform.communicationchannel.nntp.model.NntpDatum"); | ||
LASTARTICLECHECKED.setOwningType("org.eclipse.scava.platform.communicationchannel.nntp.model.NntpDatum"); | ||
DATE.setOwningType("org.eclipse.scava.platform.communicationchannel.nntp.model.NntpDatum"); | ||
} | ||
|
||
public static StringQueryProducer OSSMERTERID = new StringQueryProducer("ossmerterId"); | ||
public static NumericalQueryProducer LASTARTICLECHECKED = new NumericalQueryProducer("lastArticleChecked"); | ||
public static StringQueryProducer DATE = new StringQueryProducer("date"); | ||
|
||
|
||
public String getOssmerterId() { | ||
return parseString(dbObject.get("ossmerterId")+"", ""); | ||
} | ||
|
||
public NntpDatum setOssmerterId(String ossmerterId) { | ||
dbObject.put("ossmerterId", ossmerterId); | ||
notifyChanged(); | ||
return this; | ||
} | ||
public long getLastArticleChecked() { | ||
return parseLong(dbObject.get("lastArticleChecked")+"", 0); | ||
} | ||
|
||
public NntpDatum setLastArticleChecked(long lastArticleChecked) { | ||
dbObject.put("lastArticleChecked", lastArticleChecked); | ||
notifyChanged(); | ||
return this; | ||
} | ||
public String getDate() { | ||
return parseString(dbObject.get("date")+"", ""); | ||
} | ||
|
||
public NntpDatum setDate(String date) { | ||
dbObject.put("date", date); | ||
notifyChanged(); | ||
return this; | ||
} | ||
|
||
|
||
|
||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...p/src/org/eclipse/scava/platform/communicationchannel/nntp/model/NntpDatumCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Edge Hill University | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
******************************************************************************/ | ||
package org.eclipse.scava.platform.communicationchannel.nntp.model; | ||
|
||
import com.googlecode.pongo.runtime.*; | ||
import java.util.*; | ||
import com.mongodb.*; | ||
|
||
public class NntpDatumCollection extends PongoCollection<NntpDatum> { | ||
|
||
public NntpDatumCollection(DBCollection dbCollection) { | ||
super(dbCollection); | ||
createIndex("ossmerterId"); | ||
} | ||
|
||
public Iterable<NntpDatum> findById(String id) { | ||
return new IteratorIterable<NntpDatum>(new PongoCursorIterator<NntpDatum>(this, dbCollection.find(new BasicDBObject("_id", id)))); | ||
} | ||
|
||
public Iterable<NntpDatum> findByOssmerterId(String q) { | ||
return new IteratorIterable<NntpDatum>(new PongoCursorIterator<NntpDatum>(this, dbCollection.find(new BasicDBObject("ossmerterId", q + "")))); | ||
} | ||
|
||
public NntpDatum findOneByOssmerterId(String q) { | ||
NntpDatum nntpDatum = (NntpDatum) PongoFactory.getInstance().createPongo(dbCollection.findOne(new BasicDBObject("ossmerterId", q + ""))); | ||
if (nntpDatum != null) { | ||
nntpDatum.setPongoCollection(this); | ||
} | ||
return nntpDatum; | ||
} | ||
|
||
|
||
public long countByOssmerterId(String q) { | ||
return dbCollection.count(new BasicDBObject("ossmerterId", q + "")); | ||
} | ||
|
||
@Override | ||
public Iterator<NntpDatum> iterator() { | ||
return new PongoCursorIterator<NntpDatum>(this, dbCollection.find()); | ||
} | ||
|
||
public void add(NntpDatum nntpDatum) { | ||
super.add(nntpDatum); | ||
} | ||
|
||
public void remove(NntpDatum nntpDatum) { | ||
super.remove(nntpDatum); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ionchannel.nntp/src/org/eclipse/scava/platform/communicationchannel/nntp/model/nntp.ecore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="ASCII"?> | ||
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="org.eclipse.scava.platform.communicationchannel.nntp.model"> | ||
<eClassifiers xsi:type="ecore:EClass" name="NntpDataManager"> | ||
<eAnnotations source="db"> | ||
<details key="qualifiedCollectionNames" value="true"/> | ||
</eAnnotations> | ||
<eAnnotations source="customize"/> | ||
<eStructuralFeatures xsi:type="ecore:EReference" name="nntpData" upperBound="-1" eType="//NntpDatum" containment="true"> | ||
<eAnnotations source="series"/> | ||
</eStructuralFeatures> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="NntpDatum"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="ossmerterId"> | ||
<eAnnotations source="searchable"/> | ||
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eStructuralFeatures> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lastArticleChecked"> | ||
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//ELong"/> | ||
</eStructuralFeatures> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="date"> | ||
<eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eStructuralFeatures> | ||
</eClassifiers> | ||
</ecore:EPackage> |
16 changes: 16 additions & 0 deletions
16
...ationchannel.nntp/src/org/eclipse/scava/platform/communicationchannel/nntp/model/nntp.emf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.eclipse.scava.platform.communicationchannel.nntp.model; | ||
|
||
@db(qualifiedCollectionNames="true") | ||
@customize | ||
class NntpDataManager { | ||
@series | ||
val NntpDatum[*] nntpData; | ||
} | ||
|
||
class NntpDatum { | ||
@searchable | ||
attr String ossmerterId; | ||
attr long lastArticleChecked; | ||
attr String date; | ||
} | ||
|