CakePHP - Using JSON as a datasource - json

I'm new here so apologies in advance if I break any rules. I'm trying to use a json datasource in cakephp. I've had little progress since viewing the twitter example in the cake documentation. I can get the /model/ listing to work, but associations do not populate and I'm generally flying blind. I was wondering if anyone had any good resources they could direct me to, as the online references that I can find seem few and far between.
Thanks.
Update: My reference material was: http://book.cakephp.org/2.0/en/models/datasources.html
Embarrassing but it's just occurred to me that this code cares little about associations. It solves the problem of "How do I present data from twitter as a model in a cakephp application?" without concerning itself with assocations between other related models. Not quite the "automagic" it presented itself as, but having taken a deeper look it's safe to say that there shouldn't be any to begin with.
If I figure it out I'll post code here. I'm going to piggy-back off the dbosource file and how it's read function handles associations.

Related

Import ARIS into Rational System Architect

My basic problem is finding a way to import from an ARIS model to Rational System Architect. From what I understand from searching the IBM website and Google, it looks like it does not support loading 3rd party tools from XML (although the article is 5 years old and I cannot find anything newer). I have the export of ARIS and the DTD file to go along with it. However when I attempt to import into System Architect I get the following error...
The input contained no valid objects.
Which in my opinion makes sense - if its not setup to import from other products. But with that being said, does anyone know a way to achieve this? Searching online has yielded very little or poor results thus far.
Update - As an additional thought, I have been looking into DDL files. System architect seems to say it will work with them, however I have not been able to find out anything about how to create one using ARIS, or how they are used in general. This may end up being the solution, but sadly I am not well versed in this area yet.
The answer seems to have come down to two options.
Use a 3rd party tool to mediate the process, and convert it. Basically there is a number of other tools out there (such as ToolBus - which is the only one I found that worked for me) that convert from various applications to a single common model. From there it can be exported back to any application.
Depending on the models, the newer versions of SA can import BPMN models directly. Mind this only works for those - nothing else.

.NET WebApi jsonapi.org support

Does anyone know if there is a media formatter out there to support the jsonapi.org spec (application/vnd.api+json).
If not has anyone started (or looking at starting) a project to implement this?
For the record, as of today the answer seems to be no. Best I could find was this guy: http://www.emadibrahim.com/2014/04/09/emberjs-and-asp-net-web-api-and-json-serialization/ and that only tackles a tiny part of the problem.
I've been trying this for a while…unfortunately I tried to make something that was really smart and would automagically handle a data model from Entity Framework with almost no work. I was getting close to thinking about releasing it...and then I found out they changed a bunch of stuff in EF 6 (all models are supposed to be POCOs and the context is now a DbContext instead of an ObjectContext) and I'm probably going to have to essentially start over…which is why I started looking again to see if someone else was doing it and found your question.
Let me know if you're still looking for this, and I'll keep you updated.
UPDATE
I've just published a codeplex project that aims to provide exactly what I've described above. It's called JSONAPI.NET and while it's very early, it already does quite a bit. Documentation is sparse, and I don't have NuGet packages yet…but take a look everyone and see if it's useful for you. Feedback is encouraged! You can contact me from the project page in the link.

Dart + JSON + Neo4j: Is there a tutorial somewhere?

I've been playing around with Dart and Neo4j lately, with dreams of building Really Cool Things with these new technologies. I think I understand REST and can wrap my head around JSON. I've read both the Dart and the Neo4j documentation on using REST and JSON within each respective domain. Putting the two together, however, I have met with only very limited success. I'm really hoping someone out there might know of a tutorial or something that can get me started.
So far, I've been able to get Dart to query the database at 12.34.56.78:7474 and get it to return the address for the root node (12.34.56.78:7474/db/data) and the admin interface. When I try to query the root node, though, I get nothing back, even though, as far as I can tell in the documentation, I should be getting information about the database version and so on. At least that's what I see when I use RESTClient to view the database root node.
I'm a pretty experienced IT tech and coder, but I have to admit this is new territory for me.
Would be really cool if you could start that Dart-Neo4j integration and then let the community know about it?
/peter
To close this out, I don't think there is a tutorial for Dart + Neo4j, at the time of this writing.
You might be interested in Dart + MongoDB by using http://pub.dartlang.org/packages/mongo_dart

Is there a simple Linq to SQL generator with bi-directional serialization attributes?

I'm trying to find a way to generate Linq to SQL classes with bi-directional serialization attributes. Basically I want a DataMember tag (with an appropriate order) on every association property, not just the ones where the class is the primary key (like the Visual Studio generator and SQL Metal do). I checked MyGeneration, but didn't really find anything that worked for me. I thought the T4 Toolbox was going to be my solution, it would be quite easy to modify it to add the attributes, but I get an exception on the calling side of my WCF service, and I've gotten no response back on the issue. I'm about to try installing CodeSmith and using PLINQO, but I'd prefer something free.
I'm pretty close to just writing my own T4 generator, but before I do that, I was hoping to find an pre-built solution to this rather simple problem first.
I ended up writing my own code generator for our L2S classes. We actually generate two sets of classes. One is a "lightweight" set of entities for client application use. These classes have no L2S plumbing. But they have the full datamember attributes with proper order. Then we have our L2S entities, which are strictly for backend use. This has worked out quite well.
Be careful using PLINQO. I've looked at that product extensively. In fact, much of my code generator is based on the code PLINQO generates. However, they have a "major flaw" (their words) in how they have implemented many to many relationships.
You might want to also look at a product named "Reegenerator".
Randy
This turned out to be the solution to my problem. I had just resigned myself to start researching my own generator when I stumbled upon that. It has a bidirectional serialization option and it works great! Here's a link to the author's bog, which contains a great video example of how to get started.

How to save and load different types of objects?

During coding I frequently encounter this situation:
I have several objects (ConcreteType1, ConcreteType2, ...) with the same base type AbstractType, which has abstract methods save and load . Each object can (and has to) save some specific kind of data, by overriding the save method.
I have a list of AbstractType objects which contains various ConcreteTypeX objects.
I walk the list and the save method for each object.
At this point I think it's a good OO design. (Or am I wrong?) The problems start when I want to reload the data:
Each object can load its own data, but I have to know the concrete type in advance, so I can instantiate the right ConcreteTypeX and call the load method. So the loading method has to know a great deal about the concrete types. I usually "solved" this problem by writing some kind of marker before calling save, which is used by the loader to determine the right ConcreteTypeX.
I always had/have a bad feeling about this. It feels like some kind of anti-pattern...
Are there better ways?
EDIT:
I'm sorry for the confusion, I re-wrote some of the text.
I'm aware of serialization and perhaps there is some next-to-perfect solution in Java/.NET/yourFavoriteLanguage, but I'm searching for a general solution, which might be better and more "OOP-ish" compared to my concept.
Is this either .NET or Java? If so, why aren't you using serialisation?
If you can't simply use serialization, then I would still definitely pull the object loading logic out of the base class. Your instinct is correct, leading you to correctly identify a code smell. The base class shouldn't need to change when you change or add derived classes.
The problem is, something has to load the data and instantiate those objects. This sounds like a job for the Abstract Factory pattern.
There are better ways, but let's take a step back and look at it conceptually. What are all objects doing? Loading and Saving. When you get the object from memory, you really don't to have to care whether it gets its information from a file, a database, or the windows registry. You just want the object loaded. That's important to remember because later on, your maintanence programmer will look at the LoadFromFile() method and wonder, "Why is it called that since it really doesn't load anything from a file?"
Secondly, you're running into the issue that we all run into, and it's based in dividing work. You want a level that handles getting data from a physical source; you want a level that manipulates this data, and you want a level that displays this data. This is the crux of N-Tier Development. I've linked to an article that discusses your problem in great detail, and details how to create a Data Access Layer to resolve your issue. There are also numerous code projects here and here.
If it's Java you seek, simply substitute 'java' for .NET and search for 'Java N-Tier development'. However, besides syntactical differences, the design structure is the same.