Project

General

Profile

« Previous | Next » 

Revision 57721

refactoring

View differences:

PropagationProductToOrganizationMapper.java
82 82

  
83 83
                    final Map<byte[], byte[]> ds_org = value.getFamilyMap((DATASOURCE_RELATION_ORGANIZATION + REL_DATASOURCE_ORGANIZATION).getBytes());
84 84
                    if (MapUtils.isNotEmpty(ds_org)) {
85
                        Set<byte[]> keySet = ds_org.keySet();
86
                        if (keySet.size() != 1) {
87
                            throw new InterruptedIOException("number of organizations associated to datasource different from 1. No emit");
85

  
86
                        for(String orgId : ds_org.keySet().stream().map(String::new).collect(Collectors.toList())){
87
                            if (datasourceTypes.contains(dsType) || whiteList.contains(id)) {
88
                                valueOut.set(Value.newInstance(ONE, PRODUCT_TO_ORGANIZATION, Type.valid).toJson());
89
                                //valueOut.set(Value.newInstance(new Gson().toJson(e, Emit.class), PRODUCT_TO_ORGANIZATION, PropagationConstants.Type.valid).toJson());
90
                                context.getCounter(COUNTER_PROPAGATION, String.format("%s in propagation allowed list or id whitelisted", dsType)).increment(1);
91
                            } else {
92
                                //valueOut.set(Value.newInstance(new Gson().toJson(e, Emit.class), PRODUCT_TO_ORGANIZATION, Type.notvalid).toJson());
93
                                valueOut.set(Value.newInstance(ZERO, PRODUCT_TO_ORGANIZATION, Type.notvalid).toJson());
94
                                context.getCounter(COUNTER_PROPAGATION, String.format("%s in propagation not allowed list", dsType)).increment(1);
95
                            }
96
                            context.write(InstOrgKey.datasource(orgId), valueOut);
88 97
                        }
89
                        String orgId = ds_org.keySet().stream().map(String::new).collect(Collectors.toList()).get(0);
90
                        if (datasourceTypes.contains(dsType) || whiteList.contains(id)) {
91
                            valueOut.set(Value.newInstance(ONE, PRODUCT_TO_ORGANIZATION, Type.valid).toJson());
92
                            //valueOut.set(Value.newInstance(new Gson().toJson(e, Emit.class), PRODUCT_TO_ORGANIZATION, PropagationConstants.Type.valid).toJson());
93
                            context.getCounter(COUNTER_PROPAGATION, String.format("%s in propagation allowed list or id whitelisted", dsType)).increment(1);
94
                        } else {
95
                            //valueOut.set(Value.newInstance(new Gson().toJson(e, Emit.class), PRODUCT_TO_ORGANIZATION, Type.notvalid).toJson());
96
                            valueOut.set(Value.newInstance(ZERO, PRODUCT_TO_ORGANIZATION, Type.notvalid).toJson());
97
                            context.getCounter(COUNTER_PROPAGATION, String.format("%s in propagation not allowed list", dsType)).increment(1);
98
                        }
99
                        context.write(InstOrgKey.datasource(orgId), valueOut);
98

  
99

  
100 100
                    }
101 101

  
102 102

  
......
115 115
                    ResultProtos.Result result = entity.getResult();
116 116
                    Set<String> result_result = new HashSet<>();
117 117

  
118
                    Set<String> institution = getRelationTarget(value, REL_RESULT_ORGANIZATION, context, COUNTER_PROPAGATION);
118
                    Set<String> institution = getRelationTarget(value, RELATION_ORGANIZATION + REL_RESULT_ORGANIZATION, context, COUNTER_PROPAGATION);
119 119

  
120 120

  
121 121
                    for (String sem : sem_rels) {

Also available in: Unified diff