TinkerPop3 compatibility with Frames? - tinkerpop3

I have following below 2 queries related to TinkerPop 3:
1) Which Frames version is compatible with tinkerpop3?
2) TinkerPop3 official documentation states that the Frames feature has merged into "Traversal" but I could not found any information on that. So, please help me on this how we will implement it using Java.

Frames is no longer supported for TP3 unfortunately. But that shouldn't make you upset, there is an alternative.
Have you checked Peapod? It does what Frames do but for Tinkerpop3.
#Vertex
public abstract class Person {
public abstract String getName();
public abstract void setName(String name);
public abstract List<Knows> getKnows();
public abstract Knows getKnows(Person person);
public abstract Knows addKnows(Person person);
public abstract Knows removeKnows(Person person);
}
#Edge
public abstract class Knows {
public abstract void setYears(int years);
public abstract int getYears();
}
and then you could easily use it like this
Graph g = //define your graph heere
FramedGraph graph = new FramedGraph(g, Person.class.getPackage());
Person marko = graph.v(1, Person.class);
For more information, have a look here.
Disclaimer: I'm a contributor to Peapod.

Related

How do you explain what type of object is the show in the code?

when I create an interface object implementing the abstract methods (through anonymous classes). What type of object am I creating?
with an example the question will be better understood
public class Class1{
public static void main(String...args){
Interface1 object1= new Interface1(){
#Override
public method1(){
System.out.println("im the method");
}
}
System.out.println(Object1.getClass());
}
this returns the class Class1. how can you explain this?
an explanation of my doubt

UML class diagram for static variable from other class

As I know, if the static method from other class, we may interpret their relationship with dependency, just like the answer from How to show usage of static methods UML Class Diagram
However, how about for the static variable from other class? Is it the similar case; using dependancy?
For example,
class A{
public static String CHAR="Charecter";
public static String INT="Integer";
public static String STR="String";
}
class B{
public String Type;
public B(){
Type=STR;
}
public void B(String t){
Type=t;
}
}
would it result in the uml class diagram as below?
Note that although I would rather use enumeration in real life for this case, I just would like to know how it works.
Yes, this is similar.
Dependency shows that one class is "aware" of some other class and uses it in some way (or more generally depends on it). It can for instance refer to (public) static attributes, static operations and so on.

Entity Framework and base type with same name

I get the following error: The type 'EfTest.Person' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.
when running this code:
using System.Data.Entity;
namespace EfTest
{
internal class Program
{
private static void Main(string[] args)
{
using (var db = new PersonContext())
{
db.Persons.Add(new Person());
db.SaveChanges();
}
}
}
public class PersonContext : DbContext
{
public DbSet<Person> Persons { get; set; } //people ;)
}
public class Person : EfTest2.Person
{
public int PersonId { get; set; }
public string Name { get; set; }
}
}namespace EfTest2
{
public class Person
{
public int Age { get; set; }
}
}
can you help and explain why new type can not have same name as its base?
I would focus on the keyword nested in the error. I'm sure taking it out of EfTest2 namespace and keeping the namespace the same will correct this issue. Of course then you must change the base class name from Person to some thing else.
EF has quite complex multi-layered mapping and some of these layers are not directly visible outside. This is a problem of mapping objects into their entity representation in EDM. The point is that EF is not using full class names (including namespaces) but only bare class names so your Person classes are in collision and only one can be resolved.
The origin of this behavior is probably in EF 4.0 when it was used to simplify class creation for POCO models and make namespaces independent on the EDMX.
I think you cannot write the class next to the main session.
You have to separate it to another cs file.
I solved the problem by doing that. Worth a try

Generic search form/panel in Wicket

I am trying to implement a generic search form/panel in Wicket. The form should allow searches in several fields in an Entity (using the DAO pattern) in order to filter the output of a ListView or a DataView. What is the best way to do this? I've thought of doing this using an extended DataProvider but I haven't really seen any real example.
Did anyone implemented such a thing? Some pointers would be nice.
edit
An aditional question that might help set the direction of the answers:
Do Wicket Models combine well with DataProviders?
You can extend IDataProvider with search methods:
public interface SearchableDataProvider<T> extends IDataProvider<T> {
public void setSearchQuery(String... query);
public void clearSearchQuery();
#Override
public Iterator<? extends T> iterator(int first, int count);
#Override
public int size();
}
And implement this interface in your EntityManagers such as UserManager, ArticleManager or AccountManager.

Can/Should a domain object be responsible for converting itself to another type?

We have a class Event (it's actually named differently, but I'm just making abstraction):
public class Event
{
public string Name { get; set; }
public string Description { get; set; }
public EventType EventType { get; set; }
}
We need to build an instance of a Message class with this object, but depending on the EventType, we use a different builder:
switch (event.EventType)
{
case EventType.First:
message = FirstMessageBuilder.Build(event);
break;
case EventType.Second:
message = SecondMessageBuilder.Build(event);
break;
}
Do you think this is acceptable, or should we take the following approach:
Make an abstract class:
public class Event
{
public string Name { get; set; }
public string Description { get; set; }
public abstract Message BuildMessage();
}
Then derive two classes: class FirstMessage and class SecondMessage and make the domain objects responsible for building the message.
I hope it isn't too abstract. The bottom line is we need to transform one class to another. A simple mapper won't do, because there are properties with XML content and such (due to a legacy application making the events). Just accept what we're trying to do here.
The real question is: can a domain object be responsible for such a transformation, or would you not recommend it? I would avoid the ugly switch statement, but add complexity somewhere else.
Whilst I agree with Thomas, you might want to look at the following design patterns to see if they help you:
Vistor Pattern
Double-Dispatch Pattern
Builder Pattern
Strictly speaking, a domain object shouldn't be responsible for anything other than representing the domain. "Changing type" is clearly a technical issue and should be done by some kind of service class, to maintain a clear separation of concerns...
In order to gain the readability of
var message = eventInstance.AsMessage();
as well following the single responsibility principle, you could define AsMessage() as an extension method of the event type.
There are few possible solutions. To use abstract factory:
public interface IMessageFactory
{
Message Create();
}
public class FirstMessageFactory : IMessageFactory
{
public Message Create()
{
//...
}
}
public class SomeService
{
private readonly IMessageFactory _factory;
public SomeService(IMessageFactory factory)
{
_factory = factory;
}
public void DoSomething()
{
var message = _factory.Create();
//...
}
}
Now you can wire IoC container to right factory for requested service.
To use Assembler which makes the transformation:
public interface IAssembler<TSource, TDestination>
{
TDestination Transform(TSource source);
}
This is quite similar to factory pattern, but if you are dependent on EventType, its possible to do it like:
public interface IAssembler<TEventType>
{
object Transform(object source);
}
I would encapsulate the logic into a separate Factory/Builder class, and use an extension method on Event to call the builder.
This would give you the best of both worlds.

Resources