Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
3b8692d4
Commit
3b8692d4
authored
Feb 20, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
9e7e81da
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
0 additions
and
458 deletions
+0
-458
MongoDatabaseConnector.java
service/src/main/java/database/MongoDatabaseConnector.java
+0
-33
UserMapping.java
service/src/main/java/mappings/UserMapping.java
+0
-28
Banana.java
service/src/main/java/objects/Banana.java
+0
-34
Fruit.java
service/src/main/java/objects/Fruit.java
+0
-39
FruitMongoRepository.java
service/src/main/java/persistence/FruitMongoRepository.java
+0
-35
MongoRepositories.java
service/src/main/java/persistence/MongoRepositories.java
+0
-44
MongoRepository.java
service/src/main/java/persistence/MongoRepository.java
+0
-62
Repository.java
service/src/main/java/persistence/Repository.java
+0
-14
FruitMapping.java
service/src/main/java/persistence/mapping/FruitMapping.java
+0
-46
FruitRepository.java
service/src/main/java/repositories/FruitRepository.java
+0
-8
Repositories.java
service/src/main/java/repositories/Repositories.java
+0
-16
TasksRepository.java
service/src/main/java/repositories/TasksRepository.java
+0
-8
UsersRepository.java
service/src/main/java/repositories/UsersRepository.java
+0
-8
MongoConfiguration.java
service/src/main/java/stub/MongoConfiguration.java
+0
-53
MongoSth.java
service/src/main/java/stub/MongoSth.java
+0
-30
No files found.
service/src/main/java/database/MongoDatabaseConnector.java
deleted
100644 → 0
View file @
9e7e81da
package
database
;
import
com.mongodb.MongoClient
;
import
com.mongodb.client.FindIterable
;
import
com.mongodb.client.MongoCollection
;
import
com.mongodb.client.MongoDatabase
;
import
org.bson.Document
;
/**
* Created by gpietrus on 16.02.16.
*/
//todo: extends DatabaseConnector
public
class
MongoDatabaseConnector
{
private
MongoDatabase
mongoDatabase
;
public
MongoDatabaseConnector
()
{
//todo: move to configuration
MongoClient
mongo
=
new
MongoClient
(
"localhost"
,
27017
);
//todo: secure mode?
//todo: http://www.mkyong.com/mongodb/java-mongodb-hello-world-example/
this
.
mongoDatabase
=
mongo
.
getDatabase
(
"database name"
);
}
public
FindIterable
<
Document
>
getUsers
()
{
//todo: create user as document extension
MongoCollection
<
Document
>
users
=
mongoDatabase
.
getCollection
(
"users"
);
//todo; move "users" to configuration
FindIterable
<
Document
>
documents
=
users
.
find
();
return
documents
;
}
}
service/src/main/java/mappings/UserMapping.java
deleted
100644 → 0
View file @
9e7e81da
package
mappings
;
import
objects.User
;
import
org.mongolink.domain.mapper.AggregateMap
;
/**
* Created by gpietrus on 16.02.16.
*/
public
class
UserMapping
extends
AggregateMap
<
User
>
{
@Override
public
void
map
()
{
//todo: do not use depracted methods
id
(
element
().
getId
()).
natural
();
property
(
element
().
getUsername
());
property
(
element
().
getPassword
());
// subclass(new SubclassMap<Banana>(Banana.class) {
//
// @Override
// protected void map() {
//
// }
// });
}
}
//todo: read https://github.com/MongoLink/mongolink-example/blob/master/src/main/java/org/mongolink/example/persistence/mapping/FruitMapping.java
\ No newline at end of file
service/src/main/java/objects/Banana.java
deleted
100644 → 0
View file @
9e7e81da
/*
* 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
);
}
}
service/src/main/java/objects/Fruit.java
deleted
100644 → 0
View file @
9e7e81da
package
objects
;
import
org.joda.time.DateTime
;
import
java.util.UUID
;
public
class
Fruit
{
@SuppressWarnings
(
"UnusedDeclaration"
)
protected
Fruit
()
{
// for mongolink
}
public
Fruit
(
String
name
)
{
this
.
name
=
name
;
this
.
id
=
UUID
.
randomUUID
();
}
public
UUID
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
DateTime
getCreationDate
()
{
return
creationDate
;
}
private
UUID
id
;
private
String
name
;
private
DateTime
creationDate
=
new
DateTime
();
}
service/src/main/java/persistence/FruitMongoRepository.java
deleted
100644 → 0
View file @
9e7e81da
/*
* 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
;
import
objects.Fruit
;
import
org.mongolink.MongoSession
;
import
repositories.FruitRepository
;
public
class
FruitMongoRepository
extends
MongoRepository
<
Fruit
>
implements
FruitRepository
{
public
FruitMongoRepository
(
MongoSession
mongoSession
)
{
super
(
mongoSession
);
}
}
service/src/main/java/persistence/MongoRepositories.java
deleted
100644 → 0
View file @
9e7e81da
/*
* 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
;
import
org.mongolink.MongoSession
;
import
persistence.FruitMongoRepository
;
import
repositories.FruitRepository
;
import
repositories.Repositories
;
public
class
MongoRepositories
extends
Repositories
{
public
MongoRepositories
(
MongoSession
session
)
{
this
.
session
=
session
;
}
@Override
protected
FruitRepository
fruitsRepository
()
{
return
new
FruitMongoRepository
(
session
);
}
private
MongoSession
session
;
}
service/src/main/java/persistence/MongoRepository.java
deleted
100644 → 0
View file @
9e7e81da
/*
* 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
;
import
org.mongolink.MongoSession
;
import
java.lang.reflect.ParameterizedType
;
import
java.util.List
;
public
abstract
class
MongoRepository
<
T
>
implements
Repository
<
T
>
{
protected
MongoRepository
(
MongoSession
session
)
{
this
.
session
=
session
;
}
@Override
public
T
get
(
Object
id
)
{
return
session
.
get
(
id
,
persistentType
());
}
@Override
public
void
delete
(
T
entity
)
{
session
.
delete
(
entity
);
}
@Override
public
void
add
(
T
entity
)
{
session
.
save
(
entity
);
}
@Override
public
List
<
T
>
all
()
{
return
session
.
getAll
(
persistentType
());
}
protected
final
Class
<
T
>
persistentType
()
{
final
ParameterizedType
superclass
=
(
ParameterizedType
)
getClass
().
getGenericSuperclass
();
return
(
Class
<
T
>)
superclass
.
getActualTypeArguments
()[
0
];
}
protected
final
MongoSession
session
;
}
service/src/main/java/persistence/Repository.java
deleted
100644 → 0
View file @
9e7e81da
package
persistence
;
import
java.util.List
;
public
interface
Repository
<
T
>
{
T
get
(
Object
id
);
void
delete
(
T
entit
é
);
void
add
(
T
entit
é
);
List
<
T
>
all
();
}
service/src/main/java/persistence/mapping/FruitMapping.java
deleted
100644 → 0
View file @
9e7e81da
/*
* 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
()
{
}
});
}
}
service/src/main/java/repositories/FruitRepository.java
deleted
100644 → 0
View file @
9e7e81da
package
repositories
;
import
objects.Fruit
;
import
persistence.Repository
;
public
interface
FruitRepository
extends
Repository
<
Fruit
>
{
}
\ No newline at end of file
service/src/main/java/repositories/Repositories.java
deleted
100644 → 0
View file @
9e7e81da
package
repositories
;
public
abstract
class
Repositories
{
public
static
void
initialise
(
Repositories
instance
)
{
Repositories
.
instance
=
instance
;
}
public
static
FruitRepository
fruits
()
{
return
instance
.
fruitsRepository
();
}
protected
abstract
FruitRepository
fruitsRepository
();
private
static
Repositories
instance
;
}
service/src/main/java/repositories/TasksRepository.java
deleted
100644 → 0
View file @
9e7e81da
package
repositories
;
/**
* Created by gpietrus on 16.02.16.
*/
public
class
TasksRepository
{
}
service/src/main/java/repositories/UsersRepository.java
deleted
100644 → 0
View file @
9e7e81da
package
repositories
;
/**
* Created by gpietrus on 16.02.16.
*/
public
class
UsersRepository
{
}
service/src/main/java/stub/MongoConfiguration.java
deleted
100644 → 0
View file @
9e7e81da
/*
* 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
stub
;
import
org.mongolink.MongoSession
;
import
org.mongolink.MongoSessionManager
;
import
org.mongolink.Settings
;
import
org.mongolink.domain.mapper.ContextBuilder
;
public
class
MongoConfiguration
{
public
static
void
stop
()
{
Singleton
.
INSTANCE
.
mongoSessionManager
.
close
();
}
public
static
MongoSession
createSession
()
{
return
Singleton
.
INSTANCE
.
mongoSessionManager
.
createSession
();
}
private
enum
Singleton
{
INSTANCE
;
private
Singleton
()
{
ContextBuilder
builder
=
new
ContextBuilder
(
"persistence.mapping"
);
Settings
settings1
=
Settings
.
defaultInstance
();
Settings
settings
=
new
Properties
().
addSettings
(
settings1
);
mongoSessionManager
=
MongoSessionManager
.
create
(
builder
,
settings
);
}
private
final
MongoSessionManager
mongoSessionManager
;
}
}
service/src/main/java/stub/MongoSth.java
deleted
100644 → 0
View file @
9e7e81da
package
stub
;
import
com.google.common.collect.Lists
;
import
com.mongodb.ServerAddress
;
import
org.mongolink.MongoSession
;
import
org.mongolink.MongoSessionManager
;
import
org.mongolink.Settings
;
import
org.mongolink.UpdateStrategies
;
import
org.mongolink.domain.mapper.ContextBuilder
;
/**
* Created by gpietrus on 16.02.16.
*/
public
class
MongoSth
{
public
void
run
()
{
ContextBuilder
builder
=
new
ContextBuilder
(
"org.mongolink.example.persistence.mapping"
);
Settings
settings
=
Settings
.
defaultInstance
()
.
withDefaultUpdateStrategy
(
UpdateStrategies
.
DIFF
)
.
withDbName
(
"db"
)
.
withAddresses
(
Lists
.
newArrayList
(
new
ServerAddress
(
"localhost"
,
27017
)))
.
withAuthentication
(
"user"
,
"passwd"
);
MongoSessionManager
mongoSessionManager
=
MongoSessionManager
.
create
(
builder
,
settings
);
MongoSession
session
=
mongoSessionManager
.
createSession
();
session
.
start
();
// do stuff
session
.
stop
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment