In WebProtege, how do I reference a subclass in a property? - owl

Have class with some subclasses:
Name
- FirstName
- MiddleName
- LastName
Have class with Name as a property:
Borrower
has Address
has Name
Want to create the following class with relationship:
Title
has Borrower > Name
How do I construct the "Borrower > Name" property?

Related

How to update a model TextField based on a function output

I have a PIL function that checks the uploaded image resolution and resizes it to either a fulscreen resolution or banner resolution then saves it to the database. Now I need to add a model textfield that saves the values "fullscreen" or "banner" to the database table when the picture is saved. I have added the field to the model but I don't know where and how to update this.
You can bind your attribute that is to be derived to a function.
Example: I have a Person model with fields fname and lname.
I can derive a function :
class Person(models.Model):
lname = models.CharField(max_length=500, blank=False)
fname = models.CharField(max_length=500, blank=False)
def fullname(self):
return "%s %s"%(self.fname,self.lname)
name = property(fullname)
Whenever I do person.name it will actually return a name by combining fname and lname.

Android Room - Column conflict on entities that extend a class

I have a Patient entity which extends a base Resource object. Now Resource contains a uuid and a display, which I also want to include to the patients table, so I annotate like so:
public class Resource implements Serializable {
#ColumnInfo
protected String uuid;
#ColumnInfo
protected String display;
// getters and setters
}
And in my Patient entity, there are nested objects and they also extend from Resource (e.g. a PatientIdentifier and a Person object is embedded and has their own uuid and display):
#Entity(tableName = "patients")
public class Patient extends Resource implements Serializable {
#PrimaryKey
private Long id;
// ...
#Embedded
private PatientIdentifier identifier;
#Embedded
private Person person;
// other variables
}
this results in a column name conflict - as there is a "uuid" column for a Patient, the PatientIdentifier and the Person.
I want to rename the nested objects' uuid columns after their name (e.g. "person_uuid"), similar to the #ForeignKey annotation in entity relationships, so may I know how to do that?
You can specify the column name like that :
#ColumnInfo(name = "person_uuid")

How can i add data into my model which is many to many field for another model

This is just a example of my models and form. my question is how i can save data in my both models only using one form. i wanted to save data through my Book Form() where in book model i have created a many to many field from Author Model and if i used this form then he is telling me to first add data in author model then only select and save data in book model. through my template i wanted to render fields from my form as author title , name , date of birth and book name and when user enter all the details it should be saved in respective models only.
TITLE_CHOICES = (
('MR', 'Mr.'),
('MRS', 'Mrs.'),
('MS', 'Ms.'),
)
class Author(models.Model):
name = models.CharField(max_length=100)
title = models.CharField(max_length=3, choices=TITLE_CHOICES)
birth_date = models.DateField(blank=True, null=True)
def __str__(self):
return self.name
class Book(models.Model):
name = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
class BookForm(ModelForm):
class Meta:
model = Book
fields = ['name', 'authors']

Updating contents of Endpoints class using endpoints-proto-datastore

i have a class which inherits from EndpointsModel
class User( EndpointsModel ):
name = ndb.StructuredProperty( Name, required=True )
dateOfBirth = ndb.DateProperty(required=True)
userName = ndb.StringProperty( required=True )
emailId = ndb.StringProperty( required=True )
Now, suppose i want to update the name for some user with some username. Since, the methods for User expects a User object as input and output, do i have to create a separate message class for name and then use it to update name like i would do if i was not using endpoints-proto-datastore ?
You can define request_fields in your API method to limit the "request message" to a subset of the fields in User
#User.method(path='/user/{id}',
http_method='PUT',
name='update',
request_fields=('id', 'name'))
def update_user(self, user):
...

How to avoid a property/field without any annotation but with name "id" not mapped to '_id' field by Spring Mongo?

According to Spring Data Mongo docs
The following outlines what property will be mapped to the '_id'
document field:
A property or field annotated with #Id (org.springframework.data.annotation.Id) will be mapped to the '_id'
field.
A property or field without an annotation but named id will be mapped to the '_id' field.
I have some nested classes that have id field/property that does not need to mapped to mongo _id field but rather as a plain id field. Any tricks?
If you don't want that the id field is mapped to the mongo _id field you have to provide another field in your class with the#Id annotation. Then this field is used as mongo id and you can use the other in any way you want.
Example:
public class Foo {
#Id
private String mongoId;
// Your id
private String id;
}

Resources