Open XAVA How to Put Default value and Join column of another table - openxava

1 .For default value I have tried :
#Required
#Column(name="semester")
#DefaultValueCalculator(value=StringCalculator.class, properties=#PropertyValue(name="value", value="173"))
private String semester;
Getting error :
Error calculating default value
2 . Another Problem is I want to view column of another table into a table.
Table .
- Room [id, name]
- RoomAssigned [id , capacity , type ,status ]
In view/UI , I am showing RoomAssigned which has CRUD .
Now its showing column -
[id,capacity,type,status]
I want to add another column [name] from "Room" table . Here "Room" id is foreign key.
I want to get a view with view / UI :
[id,name,capacity,type,status]
I am new in OpenXava.Thanks in advance.

About the second point, you have to put the reference name in the #View members, use a #ReferenceView in the reference and create a #View in the referenced entity.
Read this documentation first:
http://openxava.wikispaces.com/view_en

Related

set up product filter based on multiselection field in Pimcore

Goal
I want to have a product filter based on a multiselection field of my data object.
Current setup
Project based on the official Pimcore Demo Application
Added a new data field to my data object class (type: Multiselection, name: selectionTest)
Manually update index via php bin/console ecommerce:indexservice:bootstrap --update-index
Create a new filter definition and add a FilterMultiSelectFromMultiSelect
Here I can select the field selectionTest, but the Pre Select field keeps empty (see screenshot)
select the filter definition in the product category
when I open now the product category in the shop frontend, I get following exception:
An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT TRIM(`selectionTest`) as `value`, count(*) as `count` FROM shop_productindex a WHERE active = 1 AND o_virtualProductActive = 1 AND inProductList = 1 AND o_type = 'variant' GROUP BY TRIM(`selectionTest`)':
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'selectionTest' in 'field list'").

extract posts cover images(first media) in orchard database

I want to have a query that extract all informations about blog posts in Orchard-cms Database. and i found this reference so i created some query like this:
SELECT * FROM dbo.default_Title_TitlePartRecord
inner join dbo.default_Orchard_Framework_ContentItemRecord on
dbo.default_Title_TitlePartRecord.ContentItemRecord_id=dbo.default_Orchard_Framework_ContentItemRecord.Id
inner join dbo.default_Orchard_Framework_ContentTypeRecord on
dbo.default_Orchard_Framework_ContentItemRecord.ContentType_id= dbo.default_Orchard_Framework_ContentTypeRecord.Id
inner join dbo.default_Common_BodyPartRecord on
dbo.default_Common_BodyPartRecord.ContentItemRecord_id=dbo.default_Orchard_Framework_ContentItemRecord.Id
INNER JOIN dbo.default_Orchard_Framework_ContentItemVersionRecord AS civr on
civr.ContentItemRecord_id = dbo.default_Orchard_Framework_ContentItemRecord.Id
but still i couldnt find any way to access posts first media(post image or cover image) Address!
do you know how can i get the posts image address in orchard database?
i found picture names in a table named Orchard_MediaLibrary_MediaPartRecord but there isnt any foreign key which connected to this table(maybe i didnt find it)
can any body help me ...is there any diagram for orchard database??!!
i found it... there is no foreign key field to reference image of the post. but there is a field named DATA in version row of the content item which contains an xml string.
one of the xml Elements is <image/> and contains id of image in text value.
SELECT distinct dbo.default_Orchard_Framework_ContentItemRecord.Id as postId ,
L2.Title as PostTitle ,
civr.Data --this is xml field !!!!!!!!!
FROM dbo.default_Orchard_Framework_ContentItemRecord
inner join dbo.default_Common_BodyPartRecord on
dbo.default_Common_BodyPartRecord.ContentItemRecord_id=dbo.default_Orchard_Framework_ContentItemRecord.Id
INNER JOIN dbo.default_Orchard_Framework_ContentItemVersionRecord AS civr on
civr.ContentItemRecord_id = dbo.default_Orchard_Framework_ContentItemRecord.Id
inner join dbo.default_Orchard_Framework_ContentTypeRecord on
dbo.default_Orchard_Framework_ContentItemRecord.ContentType_Id=dbo.default_Orchard_Framework_ContentTypeRecord.Id
CROSS APPLY(select top(1) Title from dbo.default_Title_TitlePartRecord where ContentItemRecord_id =dbo.default_Orchard_Framework_ContentItemRecord.Id)L2
where civr.Published=1 and dbo.default_Orchard_Framework_ContentItemRecord.ContentType_Id=9 and civr.Latest=1 order by postId desc

The Lookup drop down is not displaying code with description after selection

I have created a custom table with following fields and using it in grid for lookup. The following are the structure of the Table.
CREATE TABLE KcLocationColor
(
CompanyID int not null,
Code nvarchar(30) collate database_default,
[Description] nvarchar(512) collate database_default,
CONSTRAINT PK_LocationColor PRIMARY KEY CLUSTERED (CompanyID,Code)
)
I have declared the lookup using following statement
[PXSelector(typeof(KcLocationColor.code),
new Type[]
{
typeof(KcLocationColor.code),
typeof(KcLocationColor.description)
},
DescriptionField = typeof(KcLocationColor.description))]
After selecting only code displays not with code and description
I have used it with acumatica tables and it is working fine. I am not able to figure out the issue with custom table
Regards,
R.Muralidharan
Set respective Grid Column’s DisplayMode Property to Hint.
At run time after selecting value from PXSelector it should appear as value - description

Selecting objects in Doctrine

$queryBuilder
->add('select', 'd.item')
->add('from', 'Entities:TypeDetail d')
->add('where', $queryBuilder->expr()->andx(
$queryBuilder->expr()->gt('d.dateValue', $dates['start']),
$queryBuilder->expr()->lt('d.dateValue', $dates['end']))
);
TypeDetail (the table) has the following fields:
id, dateValue, itemId
And the model in Symfony is:
id, dateValue, item (object)
What I want to do is get a result containing only the item objects. I don't want the item id or any of the date values (while I do need them to filter the query, I don't actually care about them coming back in the response).
Is that possible? Obviously d.item as the select is not working!
Cheers

How to reference one foreign key column with multiple primary key column

I am creating BOOK_Issue table which will contain id of person to whom the book is issued.
i have a column name user_id witch will contain ids from tbl_student as well as tbl_faculty. so how to set user_id field of book_issue table with reference to two primary key columns.
Your database schema is not correct.
If you expect unique IDs then they should be in one table.
You can create a table with all the users, and have a column to set their type (student, faculty). Then create 2 different tables for each type that has the proper information for each user based on their type.
Create a "person" superclass that can be either of type "student" or type "faculty". Reference this from the BOOK_Issue table instead.
Basically to create this relationship, you'll need one unique ID that spans both "student" and "faculty". Put this in a table (tbl_person?) and have each row in tbl_student and tbl_faculty reference this new table. It's probably also best to then pull out the fields present in both tbl_student and tbl_faculty and put them in this new supertable instead.
You can solve the problem by either having an extra column in BOOK_Issue table, next to user_id, which indicates if this is a Student ID or a Faculty ID.
Alternatively, the IDs themselves may readily include some pattern which indicate their nature (for example no all faculty Ids may start with say "UC", and none of the student Id are so).
The two solutions above then allow using queries similar to the following
SELECT B.*,
CASE B.BorrowerType -- could be LEFT(user_id, 2) etc...
WHEN 'S' THEN S.Name
WHEN 'F' Then F.Name
END As Name,
CASE B.BorrowerType
WHEN 'S' THEN S.PhoneNumber
WHEN 'F' Then F.Phone -- Note that these constructs allow
-- mapping distinct columns names etc.
END As PhoneNr
FROM BOOK_Issue B
LEFT JOIN tbl_student S ON B.BorrowerType = 'S' AND B.user_id = S.id
LEFT JOIN tbl_faculty F ON B.BorrowerType = 'F' AND B.user_id = F.id
WHERE B.DueDate < '11/23/2009' -- or some other condition
This can get a bit heavy when we need to get multiple columns from the student/faculty tables. A possible alternative is a UNION, but this would then cause the repeating of the search clause.
Finally, the best solution but not avaible on all DBMS is a sub-query driven by an "IF B.BorrowerType = 'S' " condition.
This should be your table design:
FacultyTable (FacultyID, FacultyName)
StudentsTable (StudentID, StudentName, FacultlyID, ...)
BookTable (BookID, BookName, ...)
UsersTable(UserID, UserName, UserPassword, StudentID, LastLogin, ...)
Now this is the main thing:
BookIssedTable(BookIssedID, BookID, UserID)
//This table tells me that a book of "BookID was issued to a user of "UserID"
//this can be better for this is certainly a great improvement from the initial design.

Resources