if (pm.getInfo() instanceof SingleValuedPropertyInfo) {
ValueMapping pmvm = pm.getValueMapping();
//
if (pmvm instanceof SimpleMapping) {
SimpleMapping pmdm = (SimpleMapping)pmvm;
JCRMemberMapping jcrMember = pmdm.getJCRMember();
//
if (jcrMember instanceof JCRPropertyMapping) {
JCRPropertyMapping jcrProperty = (JCRPropertyMapping)jcrMember;
JCRPropertyPropertyMapper bilto = new JCRPropertyPropertyMapper((SingleValuedPropertyInfo<SimpleValueInfo>)pm.getInfo(), jcrProperty.getName());
propertyMappers.add(bilto);
} else if (jcrMember instanceof JCRNodeAttributeMapping) {
JCRNodeAttributeMapping nam = (JCRNodeAttributeMapping)jcrMember;
propertyMappers.add(new JCRNodeAttributePropertyMapper((SingleValuedPropertyInfo<SimpleValueInfo>)pm.getInfo(), nam.getType()));
}
} else if (pmvm instanceof RelationshipMapping) {
RelationshipMapping pmhm = (RelationshipMapping)pmvm;
//
if (pmhm.getType() == RelationshipType.HIERARCHIC) {
if (pmhm instanceof ManyToOneMapping) {
JCRChildNodePropertyMapper bilto = new JCRAnyChildCollectionPropertyMapper((SingleValuedPropertyInfo<BeanValueInfo>)pm.getInfo());
relatedProperties.get(pmhm.getRelatedType()).add(bilto);
propertyMappers.add(bilto);
} if (pmhm instanceof NamedOneToOneMapping) {
NamedOneToOneMapping ncpmpm = (NamedOneToOneMapping)pmhm;
if (ncpmpm.isOwner()) {
JCRNamedChildParentPropertyMapper bilto = new JCRNamedChildParentPropertyMapper((SingleValuedPropertyInfo<BeanValueInfo>)pm.getInfo(), ncpmpm.getName());
relatedProperties.get(pmhm.getRelatedType()).add(bilto);
propertyMappers.add(bilto);
} else {
JCRChildNodePropertyMapper bilto = new JCRNamedChildPropertyMapper((SingleValuedPropertyInfo<BeanValueInfo>)pm.getInfo(), ncpmpm.getName());
relatedProperties.get(ncpmpm.getRelatedType()).add(bilto);
propertyMappers.add(bilto);
}
}
}
}
//
if (pmvm instanceof ManyToOneMapping) {
if (pmvm instanceof NamedManyToOneMapping) {
NamedManyToOneMapping nmtovm = (NamedManyToOneMapping)pmvm;
LinkType linkType = relationshipToLinkMapping.get(nmtovm.getType());
if (linkType != null) {
JCRNamedReferentPropertyMapper blah = new JCRNamedReferentPropertyMapper(
(SingleValuedPropertyInfo<BeanValueInfo>)pm.getInfo(),
nmtovm.getRelatedName(),
linkType
);
propertyMappers.add(blah);
relatedProperties.get(nmtovm.getRelatedType()).add(blah);
}
}
}
} else if (pm.getInfo() instanceof MultiValuedPropertyInfo) {
ValueMapping pmvm = pm.getValueMapping();
//
if (pmvm instanceof RelationshipMapping) {
RelationshipMapping pmhm = (RelationshipMapping)pmvm;
//
if (pmhm instanceof OneToManyMapping) {
//
if (pmhm instanceof NamedOneToManyMapping) {
LinkType linkType = relationshipToLinkMapping.get(pmhm.getType());
if (linkType != null) {
NamedOneToManyMapping fff = (NamedOneToManyMapping)pmhm;
JCRReferentCollectionPropertyMapper bilto = new JCRReferentCollectionPropertyMapper(
(CollectionPropertyInfo<BeanValueInfo>)pm.getInfo(),
fff.getName(),
linkType);
relatedProperties.get(pmhm.getRelatedType()).add(bilto);
propertyMappers.add(bilto);
}
} else {
if (pmhm.getType() == RelationshipType.HIERARCHIC) {
MultiValuedPropertyInfo<BeanValueInfo> mpi = (MultiValuedPropertyInfo<BeanValueInfo>)pm.getInfo();
AnyChildMultiValueMapper valueMapper;
if (mpi instanceof MapPropertyInfo) {
valueMapper = new AnyChildMultiValueMapper.Map();
} else if (mpi instanceof CollectionPropertyInfo) {
if (mpi instanceof ListPropertyInfo) {
valueMapper = new AnyChildMultiValueMapper.List();
} else {
valueMapper = new AnyChildMultiValueMapper.Collection();
}
} else {
throw new IllegalStateException();
}
JCRAnyChildParentPropertyMapper bilto = new JCRAnyChildParentPropertyMapper(mpi, valueMapper);
relatedProperties.get(pmhm.getRelatedType()).add(bilto);
propertyMappers.add(bilto);
}
}
}
} else if (pmvm instanceof SimpleMapping) {
SimpleMapping sm = (SimpleMapping)pmvm;
JCRMemberMapping jcrMember = sm.getJCRMember();
//
if (jcrMember instanceof JCRPropertyMapping) {
JCRPropertyMapping jcrProperty = (JCRPropertyMapping)jcrMember;
JCRPropertyListPropertyMapper bilto = new JCRPropertyListPropertyMapper((MultiValuedPropertyInfo<SimpleValueInfo>)pm.getInfo(), jcrProperty.getName());