Re: help with ERAttachments
Re: help with ERAttachments
- Subject: Re: help with ERAttachments
- From: David Holt <email@hidden>
- Date: Sat, 16 Oct 2010 12:56:39 -0700
On 2010-10-16, at 11:48 AM, Theodore Petrosky wrote:
> Let me state the question again,
>
> If you ran your migration against Frontbase, would you expect your Tutorial0 to create both the Person table and the erattachment table?
Ahhh, no. The migrations for ERAttachment are happening because you have included that framework in your build path when you start up your application. If you look in the _dbupdater table, you'll see the version for ERAttachment framework model in a row in that table. You can find the migrations files in the source code for the framework. By enabling migrations at start up, you are going to run the migrations in any frameworks that contain migration classes as well (for example ERCoreBusinessLogic).
>
> I viewed the Practical Wonder podcast that explores ERAttachments and it starts with the assumption that the base table (Person) is already created and you are 'adding' attachments.
>
> If I hadn't seen the Practical Wonder webcast, I would have been lost trying to create the erattachment table.
>
> I think your webcast is fantastic. Without it, I would still be lost with ERAttachments.
>
> Ted
>
> --- On Sat, 10/16/10, David Holt <email@hidden> wrote:
>
>> From: David Holt <email@hidden>
>> Subject: Re: help with ERAttachments
>> To: "Theodore Petrosky" <email@hidden>
>> Cc: "Mike Schrag" <email@hidden>, email@hidden
>> Date: Saturday, October 16, 2010, 1:09 PM
>> Hi Theodore,
>>
>> The use of migrations was a bit beyond the scope of the
>> tutorial. I think that David LeBer covered them in last
>> year's WOWODC session "This Year's Model"
>>
>> I've never used postgresql so I don't have any experience
>> to share with you. Have you been using Migrations before
>> now?
>>
>> Another option instead of using migrations is to go into
>> the ERAttachment framework source code and generate SQL from
>> that model so that you can run it against your database.
>>
>> I suppose another option is just to download and try the
>> free FrontBase database :-) I wish there were a good
>> solution for creating tutorial apps that anyone could run
>> without a whole lot of fuss on the part of the author or the
>> audience.
>>
>> It sounds like you actually got this to work in the end, so
>> I suppose the main objective to see ERAttachment in action
>> has been accomplished.
>>
>> David
>>
>> On 2010-10-16, at 8:18 AM, Theodore Petrosky wrote:
>>
>>> postgresql and ERAttachmentMigrations
>>>
>>> if I understand correctly,
>>>
>>> //from the tutorial file.
>>>
>>> @Override
>>> public void
>> upgrade(EOEditingContext editingContext,
>> ERXMigrationDatabase database) throws Throwable {
>>>
>> ERXMigrationTable personTable =
>> database.newTableNamed("person");
>>>
>> personTable.newIntegerColumn("erattachmentid", true);
>>>
>> personTable.newLargeStringColumn("firstname", true);
>>>
>> personTable.newIntegerColumn("id", false);
>>>
>> personTable.newLargeStringColumn("lastname", true);
>>>
>> personTable.create();
>>>
>> personTable.setPrimaryKey("id");
>>>
>>>
>> personTable.addForeignKey("erattachmentid", "ERAttachment",
>> "id");
>>> }
>>>
>>> Because of the correct setup of the Properties file,
>> this should create both the "Person" and ERAttachment
>> tables? Either I don't get this part or something is left
>> out.
>>>
>>> I had to factor out the:
>>>
>>> personTable.newIntegerColumn("erattachmentid", true);
>>> personTable.addForeignKey("erattachmentid",
>> "ERAttachment", "id");
>>>
>>> then create a second migration "Tutorial1" with:
>>>
>>> package your.app.model.migrations;
>>>
>>> import
>> er.attachment.migrations.ERAttachmentMigration;
>>>
>>>
>>> public class Tutorial1dontuse extends
>> ERAttachmentMigration {
>>> public Tutorial1dontuse() {
>>> super("person",
>> "erattachmentid", true);
>>> }
>>> }
>>>
>>> Is this my problem with an incorrect setup? Or a setup
>> problem with postgresql?
>>>
>>> Obviously, I got it to work, but the implication of
>> the tutorial is that I shouldn't have needed to do the
>> second step.
>>>
>>> Ted
>>>
>>>
>>>
>>>
>>>
>>> --- On Sat, 10/16/10, Mike Schrag <email@hidden>
>> wrote:
>>>
>>> From: Mike Schrag <email@hidden>
>>> Subject: Re: help with ERAttachments
>>> To: "David Holt" <email@hidden>
>>> Cc: email@hidden,
>> "Theodore Petrosky" <email@hidden>
>>> Date: Saturday, October 16, 2010, 10:46 AM
>>>
>>> re: "/attachments" appending to your path:
>>> if
>> (!filesystemPath.contains("${")) {
>> filesystemPath = filesystemPath +
>> "/attachments/${hash}/${pk}${ext}"; }
>>> if you don't specify any variables in your path, it
>> appends them for you ... if you were to set your filesystem
>> path to "/tmp/erattachments/${hash}/${pk}${ext}, it
>> wouldn't.
>>> ms
>>> On Oct 15, 2010, at 5:05 PM, David Holt wrote:
>>> The screencast is now live thanks to Pascal.
>>> http://wocommunity.org/podcasts/ERAttachment-Tutorial.mov
>>> David
>>> On 2010-10-15, at 9:15 AM, David Holt wrote:
>>> Hello Theodore,
>>> On 2010-10-15, at 5:13 AM, Theodore Petrosky wrote:
>>> Thank you. this is perfect. (almost) of course I use
>> only postgresql and there are differences. like I had to
>> factor out of the migration0 anything dealing with the
>> erattachment table and create a second migration with:
>>>
>>> Just swap in the database plugin you need for your
>> database and get rid of the FrontBase plugin from the
>> classpath.
>>> Rerun the creation of Migration0 from EntityModeler
>> and replace the version that is in the project. That should
>> get you the tables you need in the format your database
>> uses.
>>>
>>> public class Tutorial1 extends ERAttachmentMigration
>> {
>>> public Tutorial1() {
>>> super("person",
>> "erattachmentid", true);
>>> }
>>> }
>>>
>>> and of course postgresql wants to fold all
>> table/entities to lowercase.
>>>
>>> now I can work backwards and understand what is
>> happening.
>>>
>>> Questions:
>>>
>>> I see you set in the properties:
>>>
>>> Watch the screen cast :-) which should be available
>> pretty soon. I am just making it available for Pascal to
>> post now.Also read the package overview as Kieran and Amedeo
>> suggested. It explains all the settings that are used
>> below.http://webobjects.mdimension.com/hudson/job/Wonder53/javadoc/er/attachment/package-summary.html
>>>
>>> er.attachment.Person.photo.tempFolder = /tmp
>>> er.attachment.Person.photo.maxSize = 2097152
>>>
>>> Max file size allowed for upload
>>> er.attachment.Person.photo.storageType = file
>>>
>>> file, db or S3
>>> er.attachment.Person.photo.file.overwrite = false
>>>
>>> If true, a file with the same name overwrites, if
>> false it adds a value to make the filename unique
>>> er.attachment.Person.photo.file.filesystemPath =
>> /tmp/erattachment
>>>
>>> path to root folder for attachments
>>> In the development mode, where is this location. (I
>> can not find the attachment folder)
>>>
>>> It will create any folders it needs in the system
>> path. The only caveat is that it needs to be writeable by
>> the application (in development OR deployment)
>>> In deployment, where is webobjects expecting this to
>> live?
>>>
>>> Doesn't matter. I think I am using
>> /Library/WebServer/Documents/ApplicationName/AttachmentIf
>> you use the filesystem you'll likely need to make the folder
>> writeable for your application.You can also use Amazon S3 or
>> your database. It is all completely configurable.
>>>
>>> Thank you for this wonderful example.
>>>
>>> You are most welcome.
>>> David
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden