Skip to content

Commit

Permalink
refs #52 @XlsHorizontalRecordsで、@XlsPostSaveアノテーションを付与したメソッドが実行されない事象を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
mygreen committed Jun 17, 2015
1 parent 5d142c9 commit b151d65
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/gh/mygreen/xlsmapper/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,7 @@ public static void invokeNeedProcessMethod(final Method method, final Object obj
}

try {
method.setAccessible(true);
method.invoke(object, paramValues);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Throwable t = e.getCause() == null ? e : e.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ public <A extends Annotation> LoadingFieldProcessor<A> getLoadingProcessor(final
return (LoadingFieldProcessor<A>) loadingPocessorMap.get(anno.annotationType());
}

/**
* アノテーションに対する{@link LoadingFieldProcessor}を取得する。
* @param annoClass
* @return 見つからない場合はnullを返す。
*/
@SuppressWarnings("unchecked")
public <A extends Annotation> LoadingFieldProcessor<A> getLoadingProcessor(final Class<A> annoClass) {
ArgUtils.notNull(annoClass, "annoClass");

return (LoadingFieldProcessor<A>) loadingPocessorMap.get(annoClass);
}

/**
* アノテーションに対する{@link SavingFieldProcessor}を取得する。
* @param anno
Expand All @@ -159,7 +171,19 @@ public <A extends Annotation> LoadingFieldProcessor<A> getLoadingProcessor(final
public <A extends Annotation> SavingFieldProcessor<A> getSavingProcessor(final Annotation anno) {
ArgUtils.notNull(anno, "anno");

return (SavingFieldProcessor<A>) savingPocessorMap.get(anno.annotationType());
return (SavingFieldProcessor<A>) getSavingProcessor(anno.annotationType());
}

/**
* アノテーションに対する{@link SavingFieldProcessor}を取得する。
* @param annoClass
* @return 見つからない場合はnullを返す。
*/
@SuppressWarnings("unchecked")
public <A extends Annotation> SavingFieldProcessor<A> getSavingProcessor(final Class<A> annoClass) {
ArgUtils.notNull(annoClass, "annoClass");

return (SavingFieldProcessor<A>) savingPocessorMap.get(annoClass);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@ public RecordHeader(final String headerLabel, final int headerRange) {
this.headerRange = headerRange;
}

@Override
public String toString() {
return "RecordHeader [headerLabel=" + headerLabel + ", headerRange=" + headerRange + "]";
}

/**
* ヘッダーの見出しの取得
* @return
*/
public String getHeaderLabel() {
return headerLabel;
}

/**
* このヘッダーの見出しが定義されている位置が、表の開始位置から離れている距離。
* @return
*/
public int getHeaderRange() {
return headerRange;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.gh.mygreen.xlsmapper.annotation.XlsIsEmpty;
import com.gh.mygreen.xlsmapper.annotation.XlsMapColumns;
import com.gh.mygreen.xlsmapper.annotation.XlsPostLoad;
import com.gh.mygreen.xlsmapper.annotation.XlsPostSave;
import com.gh.mygreen.xlsmapper.annotation.XlsPreLoad;
import com.gh.mygreen.xlsmapper.annotation.XlsPreSave;
import com.gh.mygreen.xlsmapper.cellconvert.CellConverter;
Expand Down Expand Up @@ -810,8 +811,6 @@ record = result.get(r);
}
}

//TODO
// System.out.printf("hColumn=%d\n", hColumn);
hColumn++;
}

Expand All @@ -820,6 +819,16 @@ record = result.get(r);
saveMapColumn(sheet, headers, initColumn, hRow, record, terminal, anno, config, work, recordOperation);
}

if(record != null) {
// set PostProcess method
for(Method method : record.getClass().getMethods()) {
final XlsPostSave postProcessAnno = work.getAnnoReader().getAnnotation(record.getClass(), method, XlsPostSave.class);
if(postProcessAnno != null) {
work.addNeedPostProcess(new NeedProcess(record, method));
}
}
}

// パスの位置の変更
work.getErrors().popNestedPath();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.gh.mygreen.xlsmapper.annotation.XlsIsEmpty;
import com.gh.mygreen.xlsmapper.annotation.XlsMapColumns;
import com.gh.mygreen.xlsmapper.annotation.XlsPostLoad;
import com.gh.mygreen.xlsmapper.annotation.XlsPostSave;
import com.gh.mygreen.xlsmapper.annotation.XlsPreLoad;
import com.gh.mygreen.xlsmapper.annotation.XlsPreSave;
import com.gh.mygreen.xlsmapper.annotation.XlsVerticalRecords;
Expand Down Expand Up @@ -775,6 +776,16 @@ record = result.get(r);
saveMapColumn(sheet, headers, initRow, hColumn, record, terminal, anno, config, work, recordOperation);
}

if(record != null) {
// set PostProcess method
for(Method method : record.getClass().getMethods()) {
final XlsPostSave postProcessAnno = work.getAnnoReader().getAnnotation(record.getClass(), method, XlsPostSave.class);
if(postProcessAnno != null) {
work.addNeedPostProcess(new NeedProcess(record, method));
}
}
}

// パスの位置の変更
work.getErrors().popNestedPath();

Expand Down

0 comments on commit b151d65

Please sign in to comment.