Commit 9e7e81da authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

not working mongolink

parent 1ea08633
...@@ -6,7 +6,7 @@ import io.dropwizard.setup.Environment; ...@@ -6,7 +6,7 @@ import io.dropwizard.setup.Environment;
import objects.Fruit; import objects.Fruit;
import org.bson.Document; import org.bson.Document;
import org.mongolink.MongoSession; import org.mongolink.MongoSession;
import repositories.MongoRepositories; import persistence.MongoRepositories;
import repositories.Repositories; import repositories.Repositories;
import stub.MongoConfiguration; import stub.MongoConfiguration;
......
/*
* MongoLink, Object Document Mapper for Java and MongoDB
*
* Copyright (c) 2012, Arpinum or third-party contributors as
* indicated by the @author tags
*
* MongoLink is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MongoLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Lesser GNU General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with MongoLink. If not, see <http://www.gnu.org/licenses/>.
*
*/
package objects;
public class Banana extends Fruit {
protected Banana() {
// for mongolink
}
public Banana(String name) {
super(name);
}
}
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
*/ */
package repositories; package persistence;
import objects.Fruit; import objects.Fruit;
import org.mongolink.MongoSession; import org.mongolink.MongoSession;
import repositories.FruitRepository;
public class FruitMongoRepository extends MongoRepository<Fruit> implements FruitRepository { public class FruitMongoRepository extends MongoRepository<Fruit> implements FruitRepository
{
public FruitMongoRepository(MongoSession mongoSession) { public FruitMongoRepository(MongoSession mongoSession) {
super(mongoSession); super(mongoSession);
} }
......
...@@ -19,11 +19,15 @@ ...@@ -19,11 +19,15 @@
* *
*/ */
package repositories; package persistence;
import org.mongolink.MongoSession; import org.mongolink.MongoSession;
import persistence.FruitMongoRepository;
import repositories.FruitRepository;
import repositories.Repositories;
public class MongoRepositories extends Repositories { public class MongoRepositories extends Repositories
{
public MongoRepositories(MongoSession session) { public MongoRepositories(MongoSession session) {
this.session = session; this.session = session;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
*/ */
package repositories; package persistence;
import org.mongolink.MongoSession; import org.mongolink.MongoSession;
......
package repositories; package persistence;
import java.util.List; import java.util.List;
......
/*
* MongoLink, Object Document Mapper for Java and MongoDB
*
* Copyright (c) 2012, Arpinum or third-party contributors as
* indicated by the @author tags
*
* MongoLink is free software: you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MongoLink is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Lesser GNU General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with MongoLink. If not, see <http://www.gnu.org/licenses/>.
*
*/
package persistence.mapping;
import objects.Banana;
import objects.Fruit;
import org.mongolink.domain.mapper.AggregateMap;
import org.mongolink.domain.mapper.SubclassMap;
@SuppressWarnings("UnusedDeclaration")
public class FruitMapping extends AggregateMap<Fruit>
{
@Override
public void map() {
id().onProperty(element().getId()).natural();
property().onField("name");
property().onProperty(element().getCreationDate());
subclass(new SubclassMap<Banana>() {
@Override
public void map() {
}
});
}
}
package repositories; package repositories;
import objects.Fruit; import objects.Fruit;
import persistence.Repository;
public interface FruitRepository extends Repository<Fruit> { public interface FruitRepository extends Repository<Fruit>
{
} }
\ No newline at end of file
...@@ -42,8 +42,10 @@ public class MongoConfiguration ...@@ -42,8 +42,10 @@ public class MongoConfiguration
INSTANCE; INSTANCE;
private Singleton() { private Singleton() {
ContextBuilder builder = new ContextBuilder("org.mongolink.example.persistence.mapping"); ContextBuilder builder = new ContextBuilder("persistence.mapping");
mongoSessionManager = MongoSessionManager.create(builder, new Properties().addSettings(Settings.defaultInstance())); Settings settings1 = Settings.defaultInstance();
Settings settings = new Properties().addSettings(settings1);
mongoSessionManager = MongoSessionManager.create(builder, settings);
} }
private final MongoSessionManager mongoSessionManager; private final MongoSessionManager mongoSessionManager;
......
...@@ -2,8 +2,6 @@ package stub; ...@@ -2,8 +2,6 @@ package stub;
import org.mongolink.Settings; import org.mongolink.Settings;
import java.io.InputStream;
public class Properties public class Properties
{ {
...@@ -14,44 +12,50 @@ public class Properties ...@@ -14,44 +12,50 @@ public class Properties
} }
public String getDBHost() { public String getDBHost() {
return getProperty("db.host"); return "127.0.0.1";
// return "localhost";
// return getProperty("db.host");
} }
public String getDBName() { public String getDBName() {
return getProperty("db.name"); return "db";
// return getProperty("db.name");
} }
public int getDBPort() { public int getDBPort() {
return Integer.valueOf(getProperty("db.port")); return 27017;
// return Integer.valueOf(getProperty("db.port"));
} }
public String getDBUser() { public String getDBUser() {
return getProperty("db.user"); return "user";
// return getProperty("db.user");
} }
public String getDBPassword() { public String getDBPassword() {
return getProperty("db.password"); return "passwd";
} // return getProperty("db.password");
}
private String getProperty(String nom) {
return Config.INSTANCE.properties.getProperty(nom); // private String getProperty(String nom) {
} // return Config.INSTANCE.properties.getProperty(nom);
// }
private static enum Config {
INSTANCE; // private static enum Config {
// INSTANCE;
private Config() { //
InputStream stream = getClass().getClassLoader().getResourceAsStream("conf.properties"); // private Config() {
properties = new java.util.Properties(); // InputStream stream = getClass().getClassLoader().getResourceAsStream("conf.properties");
try { // properties = new java.util.Properties();
properties.load(stream); // try {
stream.close(); // properties.load(stream);
} catch (Exception e) { // stream.close();
// // } catch (Exception e) {
} // //
} // }
// }
private final java.util.Properties properties; //
} // private final java.util.Properties properties;
// }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment