Created
September 23, 2015 15:22
-
-
Save alexshenia/fafabac7ad0992ccde21 to your computer and use it in GitHub Desktop.
file.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<BOProduct> interrelatedProductList() { | |
List<BOProduct> list = new ArrayList<BOProduct>(); | |
BOProduct product = inheritInterrelatedProducts() ? parentRelationship().parent() : this; | |
for (BOInterrelatedProduct interrelatedProduct : interrelatedProductRelationList()) { | |
if (interrelatedProduct.product1() == null) { | |
continue; | |
} | |
if (interrelatedProduct.product1().primaryKey() == null) { | |
// the list may contain not yet saved products | |
list.add(interrelatedProduct.product2()); | |
continue; | |
} | |
if (product.primaryKey().equals(interrelatedProduct.product1().primaryKey())) { | |
list.add(interrelatedProduct.product2()); | |
} else if (product.primaryKey().equals(interrelatedProduct.product2().primaryKey())) { | |
list.add(interrelatedProduct.product1()); | |
} | |
} | |
return list; | |
} | |
private NSArray<BOInterrelatedProduct> interrelatedProductListInternal() { | |
NSArray<BOInterrelatedProduct> interrelatedProducts = new NSMutableArray<BOInterrelatedProduct>(); | |
NSArray<BOInterrelatedProduct> otherSideOfInterrelatedProducsts = BOInterrelatedProduct.fetchBOInterrelatedProducts( | |
editingContext(), BOInterrelatedProduct.PRODUCT2.eq(this), null); | |
for (BOInterrelatedProduct interrelatedProduct : otherSideOfInterrelatedProducsts) { | |
if (interrelatedProduct.product1() == null) { | |
continue; | |
} | |
for (BOInterrelatedProduct ip : interrelatedProduct.product1().interrelatedProducts()) { | |
if (ip.product2().equals(this)) { | |
interrelatedProducts.add(ip); | |
} | |
} | |
} | |
interrelatedProducts.addAll(interrelatedProducts()); | |
return interrelatedProducts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment