Skip to content

Commit

Permalink
Issue #3346 was fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Jan 8, 2015
1 parent 85760d4 commit 7d8ca09
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public class OImmutableClass implements OClass {
private final float classOverSize;
private final String shortName;
private final Map<String, String> customFields;
private final OImmutableSchema schema;

private final OImmutableSchema schema;
// do not do it volatile it is already SAFE TO USE IT in MT mode.
private OImmutableClass superClass;
// do not do it volatile it is already SAFE TO USE IT in MT mode.
Expand Down Expand Up @@ -75,7 +76,7 @@ public OImmutableClass(OClass oClass, OImmutableSchema schema) {

properties = new HashMap<String, OProperty>();
for (OProperty p : oClass.declaredProperties())
properties.put(p.getName().toLowerCase(), new OImmutableProperty(p));
properties.put(p.getName().toLowerCase(), new OImmutableProperty(p, this));

customFields = new HashMap<String, String>();
for (String key : oClass.getCustomKeys())
Expand Down Expand Up @@ -322,7 +323,11 @@ public int[] getPolymorphicClusterIds() {
return polymorphicClusterIds;
}

@Override
public OImmutableSchema getSchema() {
return schema;
}

@Override
public Collection<OClass> getBaseClasses() {
initBaseClasses();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ public class OImmutableProperty implements OProperty {
private final String name;
private final String fullName;
private final OType type;
private final OClass linkedClass;

//do not make it volatile it is already thread safe.
private OClass linkedClass = null;

private final String linkedClassName;

private final OType linkedType;
private final boolean notNull;
private final OCollate collate;
Expand All @@ -27,11 +32,16 @@ public class OImmutableProperty implements OProperty {
private final Integer id;
private final boolean readOnly;

public OImmutableProperty(OProperty property) {
public OImmutableProperty(OProperty property, OImmutableClass owner) {
name = property.getName();
fullName = property.getFullName();
type = property.getType();
linkedClass = property.getLinkedClass();

if (property.getLinkedClass() != null)
linkedClassName = property.getLinkedClass().getName();
else
linkedClassName = null;

linkedType = property.getLinkedType();
notNull = property.isNotNull();
collate = property.getCollate();
Expand All @@ -44,7 +54,7 @@ public OImmutableProperty(OProperty property) {
for (String key : property.getCustomKeys())
customProperties.put(key, property.getCustom(key));

owner = property.getOwnerClass();
this.owner = owner;
id = property.getId();
readOnly = property.isReadonly();
}
Expand Down Expand Up @@ -76,6 +86,15 @@ public OType getType() {

@Override
public OClass getLinkedClass() {
if (linkedClassName == null)
return null;

if(linkedClass != null)
return linkedClass;

OSchema schema = ((OImmutableClass)owner).getSchema();
linkedClass = schema.getClass(linkedClassName);

return linkedClass;
}

Expand Down

0 comments on commit 7d8ca09

Please sign in to comment.